1
1
/* global describe, it */
2
2
3
+ const assert = require ( 'assert' )
3
4
const { spawnSync } = require ( 'child_process' )
4
5
const c8Path = require . resolve ( '../bin/c8' )
5
6
const nodePath = process . execPath
6
7
7
8
require ( 'chai' ) . should ( )
9
+ const shouldInclude = ( actual , expected ) => {
10
+ if ( ! actual [ expected instanceof RegExp ? 'match' : 'includes' ] ( expected ) ) {
11
+ throw new assert . AssertionError ( { actual, expected, operator : 'deepEqual' } )
12
+ }
13
+ }
8
14
9
15
describe ( 'c8' , ( ) => {
10
16
it ( 'reports coverage for script that exits normally' , ( ) => {
@@ -15,7 +21,7 @@ describe('c8', () => {
15
21
nodePath ,
16
22
require . resolve ( './fixtures/normal' )
17
23
] )
18
- output . toString ( 'utf8' ) . should . include ( `
24
+ shouldInclude ( output . toString ( 'utf8' ) , `
19
25
-----------|----------|----------|----------|----------|-------------------|
20
26
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
21
27
-----------|----------|----------|----------|----------|-------------------|
@@ -33,7 +39,7 @@ All files | 91.18 | 88.89 | 0 | 91.18 | |
33
39
nodePath ,
34
40
require . resolve ( './fixtures/multiple-spawn' )
35
41
] )
36
- output . toString ( 'utf8' ) . should . include ( `
42
+ shouldInclude ( output . toString ( 'utf8' ) , `
37
43
--------------------|----------|----------|----------|----------|-------------------|
38
44
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
39
45
--------------------|----------|----------|----------|----------|-------------------|
@@ -60,7 +66,7 @@ All files | 94.12 | 70.59 | 0 | 94.12 |
60
66
nodePath ,
61
67
require . resolve ( './fixtures/multiple-spawn' )
62
68
] )
63
- output . toString ( 'utf8' ) . should . match (
69
+ shouldInclude ( output . toString ( 'utf8' ) ,
64
70
/ E r r o r : E N O E N T : n o s u c h f i l e o r d i r e c t o r y .* l o a d e r s \. j s /
65
71
)
66
72
} )
0 commit comments