@@ -16,7 +16,9 @@ const runJest = require('../runJest');
16
16
const DIR = path . resolve ( __dirname , '../coverage-report' ) ;
17
17
18
18
test ( 'outputs coverage report' , ( ) => {
19
- const { stdout, status} = runJest ( DIR , [ '--no-cache' , '--coverage' ] ) ;
19
+ const { stdout, status} = runJest ( DIR , [ '--no-cache' , '--coverage' ] , {
20
+ stripAnsi : true ,
21
+ } ) ;
20
22
const coverageDir = path . resolve ( __dirname , '../coverage-report/coverage' ) ;
21
23
22
24
// - the `setup.js` file is ignored and should not be in the coverage report.
@@ -31,39 +33,51 @@ test('outputs coverage report', () => {
31
33
} ) ;
32
34
33
35
test ( 'collects coverage only from specified file' , ( ) => {
34
- const { stdout} = runJest ( DIR , [
35
- '--no-cache' ,
36
- '--coverage' ,
37
- '--collectCoverageFrom' , // overwrites the one in package.json
38
- 'setup.js' ,
39
- ] ) ;
36
+ const { stdout} = runJest (
37
+ DIR ,
38
+ [
39
+ '--no-cache' ,
40
+ '--coverage' ,
41
+ '--collectCoverageFrom' , // overwrites the one in package.json
42
+ 'setup.js' ,
43
+ ] ,
44
+ { stripAnsi : true } ,
45
+ ) ;
40
46
41
47
// Coverage report should only have `setup.js` coverage info
42
48
expect ( stdout ) . toMatchSnapshot ( ) ;
43
49
} ) ;
44
50
45
51
test ( 'collects coverage only from multiple specified files' , ( ) => {
46
- const { stdout} = runJest ( DIR , [
47
- '--no-cache' ,
48
- '--coverage' ,
49
- '--collectCoverageFrom' ,
50
- 'setup.js' ,
51
- '--collectCoverageFrom' ,
52
- 'OtherFile.js' ,
53
- ] ) ;
52
+ const { stdout} = runJest (
53
+ DIR ,
54
+ [
55
+ '--no-cache' ,
56
+ '--coverage' ,
57
+ '--collectCoverageFrom' ,
58
+ 'setup.js' ,
59
+ '--collectCoverageFrom' ,
60
+ 'OtherFile.js' ,
61
+ ] ,
62
+ { stripAnsi : true } ,
63
+ ) ;
54
64
55
65
expect ( stdout ) . toMatchSnapshot ( ) ;
56
66
} ) ;
57
67
58
68
test ( 'collects coverage only from specified files avoiding dependencies' , ( ) => {
59
- const { stdout} = runJest ( DIR , [
60
- '--no-cache' ,
61
- '--coverage' ,
62
- '--collectCoverageOnlyFrom' ,
63
- 'Sum.js' ,
64
- '--' ,
65
- 'Sum.test.js' ,
66
- ] ) ;
69
+ const { stdout} = runJest (
70
+ DIR ,
71
+ [
72
+ '--no-cache' ,
73
+ '--coverage' ,
74
+ '--collectCoverageOnlyFrom' ,
75
+ 'Sum.js' ,
76
+ '--' ,
77
+ 'Sum.test.js' ,
78
+ ] ,
79
+ { stripAnsi : true } ,
80
+ ) ;
67
81
68
82
// Coverage report should only have `sum.js` coverage info
69
83
expect ( stdout ) . toMatchSnapshot ( ) ;
@@ -106,7 +120,7 @@ test('collects coverage from duplicate files avoiding shared cache', () => {
106
120
runJest ( DIR , args ) ;
107
121
108
122
// Run for the second time
109
- const { stdout, status} = runJest ( DIR , args ) ;
123
+ const { stdout, status} = runJest ( DIR , args , { stripAnsi : true } ) ;
110
124
expect ( stdout ) . toMatchSnapshot ( ) ;
111
125
expect ( status ) . toBe ( 0 ) ;
112
126
} ) ;
0 commit comments