File tree 3 files changed +66
-2
lines changed
packages/builders/src/jest
3 files changed +66
-2
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,48 @@ describe('Jest Builder', () => {
45
45
) ;
46
46
} ) ;
47
47
48
- it ( 'should send the setupFile to jestCLI' , ( ) => {
48
+ it ( 'should send other options to jestCLI' , ( ) => {
49
+ const runCLI = spyOn ( jestCLI , 'runCLI' ) . and . returnValue (
50
+ Promise . resolve ( {
51
+ results : {
52
+ success : true
53
+ }
54
+ } )
55
+ ) ;
56
+ const root = normalize ( '/root' ) ;
57
+ builder
58
+ . run ( {
59
+ root,
60
+ builder : '' ,
61
+ projectType : 'application' ,
62
+ options : {
63
+ jestConfig : './jest.config.js' ,
64
+ tsConfig : './tsconfig.test.json' ,
65
+ watch : false ,
66
+ codeCoverage : true ,
67
+ ci : true ,
68
+ updateSnapshot : true
69
+ }
70
+ } )
71
+ . toPromise ( ) ;
72
+ expect ( runCLI ) . toHaveBeenCalledWith (
73
+ {
74
+ globals : JSON . stringify ( {
75
+ 'ts-jest' : {
76
+ tsConfigFile : path . relative ( root , './tsconfig.test.json' )
77
+ } ,
78
+ __TRANSFORM_HTML__ : true
79
+ } ) ,
80
+ watch : false ,
81
+ coverage : true ,
82
+ ci : true ,
83
+ updateSnapshot : true
84
+ } ,
85
+ [ './jest.config.js' ]
86
+ ) ;
87
+ } ) ;
88
+
89
+ it ( 'should send the main to jestCLI' , ( ) => {
49
90
const runCLI = spyOn ( jestCLI , 'runCLI' ) . and . returnValue (
50
91
Promise . resolve ( {
51
92
results : {
Original file line number Diff line number Diff line change @@ -15,7 +15,10 @@ export interface JestBuilderOptions {
15
15
jestConfig : string ;
16
16
tsConfig : string ;
17
17
watch : boolean ;
18
+ ci ?: boolean ;
19
+ codeCoverage ?: boolean ;
18
20
setupFile ?: string ;
21
+ updateSnapshot ?: boolean ;
19
22
}
20
23
21
24
export default class JestBuilder implements Builder < JestBuilderOptions > {
@@ -25,6 +28,9 @@ export default class JestBuilder implements Builder<JestBuilderOptions> {
25
28
const options = builderConfig . options ;
26
29
const config : any = {
27
30
watch : options . watch ,
31
+ coverage : options . codeCoverage ,
32
+ ci : options . ci ,
33
+ updateSnapshot : options . updateSnapshot ,
28
34
globals : JSON . stringify ( {
29
35
'ts-jest' : {
30
36
tsConfigFile : path . relative ( builderConfig . root , options . tsConfig )
Original file line number Diff line number Diff line change 19
19
},
20
20
"watch" : {
21
21
"type" : " boolean" ,
22
- "description" : " Run tests when files change." ,
22
+ "description" :
23
+ " Run tests when files change. (https://jestjs.io/docs/en/cli#watch)" ,
23
24
"default" : false
25
+ },
26
+ "codeCoverage" : {
27
+ "type" : " boolean" ,
28
+ "description" :
29
+ " Export a code coverage report. (https://jestjs.io/docs/en/cli#coverage)"
30
+ },
31
+ "updateSnapshot" : {
32
+ "type" : " boolean" ,
33
+ "alias" : " u" ,
34
+ "description" :
35
+ " Re-record all failing snapshots. (https://jestjs.io/docs/en/cli#updatesnapshot)"
36
+ },
37
+ "ci" : {
38
+ "type" : " boolean" ,
39
+ "description" :
40
+ " Fail on missing snapshots. (https://jestjs.io/docs/en/cli#ci)"
24
41
}
25
42
},
26
43
"required" : [" jestConfig" , " tsConfig" ]
You can’t perform that action at this time.
0 commit comments