3
3
const { spawnSync } = require ( 'child_process' )
4
4
const c8Path = require . resolve ( '../bin/c8' )
5
5
const nodePath = process . execPath
6
+ const chaiJestSnapshot = require ( 'chai-jest-snapshot' )
6
7
7
- require ( 'chai' ) . should ( )
8
+ require ( 'chai' )
9
+ . use ( chaiJestSnapshot )
10
+ . should ( )
11
+
12
+ beforeEach ( function ( ) { chaiJestSnapshot . configureUsingMochaContext ( this ) } )
8
13
9
14
describe ( 'c8' , ( ) => {
10
15
it ( 'reports coverage for script that exits normally' , ( ) => {
@@ -15,14 +20,7 @@ describe('c8', () => {
15
20
nodePath ,
16
21
require . resolve ( './fixtures/normal' )
17
22
] )
18
- output . toString ( 'utf8' ) . should . include ( `
19
- -----------|----------|----------|----------|----------|-------------------|
20
- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
21
- -----------|----------|----------|----------|----------|-------------------|
22
- All files | 91.18 | 88.89 | 0 | 91.18 | |
23
- async.js | 100 | 100 | 100 | 100 | |
24
- normal.js | 85.71 | 75 | 0 | 85.71 | 14,15,16 |
25
- -----------|----------|----------|----------|----------|-------------------|` )
23
+ output . toString ( 'utf8' ) . should . matchSnapshot ( )
26
24
} )
27
25
28
26
it ( 'merges reports from subprocesses together' , ( ) => {
@@ -33,22 +31,7 @@ All files | 91.18 | 88.89 | 0 | 91.18 | |
33
31
nodePath ,
34
32
require . resolve ( './fixtures/multiple-spawn' )
35
33
] )
36
- output . toString ( 'utf8' ) . should . include ( `
37
- --------------------|----------|----------|----------|----------|-------------------|
38
- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
39
- --------------------|----------|----------|----------|----------|-------------------|
40
- All files | 94.12 | 70.59 | 0 | 94.12 | |
41
- bin | 83.72 | 57.14 | 100 | 83.72 | |
42
- c8.js | 83.72 | 57.14 | 100 | 83.72 |... 22,40,41,42,43 |
43
- lib | 96.41 | 65.38 | 100 | 96.41 | |
44
- parse-args.js | 97.47 | 44.44 | 100 | 97.47 | 55,56 |
45
- report.js | 95.45 | 76.47 | 100 | 95.45 | 51,52,53,54 |
46
- test/fixtures | 95.16 | 83.33 | 0 | 95.16 | |
47
- async.js | 100 | 100 | 100 | 100 | |
48
- multiple-spawn.js | 100 | 100 | 100 | 100 | |
49
- normal.js | 85.71 | 75 | 0 | 85.71 | 14,15,16 |
50
- subprocess.js | 100 | 71.43 | 100 | 100 | 9,13 |
51
- --------------------|----------|----------|----------|----------|-------------------|` )
34
+ output . toString ( 'utf8' ) . should . matchSnapshot ( )
52
35
} )
53
36
54
37
it ( 'omit-relative can be set to false' , ( ) => {
0 commit comments