@@ -18,41 +18,41 @@ const {
1818 deprecatedConfig,
1919} = require ( './fixtures/jest_config' ) ;
2020
21- test ( 'validates default Jest config' , ( ) => {
21+ test ( 'recursively validates default Jest config' , ( ) => {
2222 expect (
2323 validate ( defaultConfig , {
2424 exampleConfig : validConfig ,
25+ recursive : true ,
2526 } ) ,
2627 ) . toEqual ( {
2728 hasDeprecationWarnings : false ,
2829 isValid : true ,
2930 } ) ;
3031} ) ;
3132
32- test ( 'validates default jest-validate config' , ( ) => {
33+ test ( 'recursively validates default jest-validate config' , ( ) => {
3334 expect (
3435 validate ( jestValidateDefaultConfig , {
3536 exampleConfig : jestValidateExampleConfig ,
37+ recursive : true ,
3638 } ) ,
3739 ) . toEqual ( {
3840 hasDeprecationWarnings : false ,
3941 isValid : true ,
4042 } ) ;
4143} ) ;
4244
43- [
44- [ { automock : [ ] } , 'Boolean' ] ,
45- [ { coverageReporters : { } } , 'Array' ] ,
46- [ { preset : 1337 } , 'String' ] ,
47- [ { haste : 42 } , 'Object' ] ,
48- ] . forEach ( ( [ config , type ] ) => {
49- test ( `pretty prints valid config for ${ type } ` , ( ) => {
50- expect ( ( ) =>
51- validate ( config , {
52- exampleConfig : validConfig ,
53- } ) ,
54- ) . toThrowErrorMatchingSnapshot ( ) ;
55- } ) ;
45+ test . each ( [
46+ [ 'Boolean' , { automock : [ ] } ] ,
47+ [ 'Array' , { coverageReporters : { } } ] ,
48+ [ 'String' , { preset : 1337 } ] ,
49+ [ 'Object' , { haste : 42 } ] ,
50+ ] ) ( 'pretty prints valid config for %s' , ( type , config ) => {
51+ expect ( ( ) =>
52+ validate ( config , {
53+ exampleConfig : validConfig ,
54+ } ) ,
55+ ) . toThrowErrorMatchingSnapshot ( ) ;
5656} ) ;
5757
5858test ( `pretty prints valid config for Function` , ( ) => {
@@ -61,6 +61,7 @@ test(`pretty prints valid config for Function`, () => {
6161 expect ( ( ) =>
6262 validate ( config , {
6363 exampleConfig : validConfig ,
64+ recursive : true ,
6465 } ) ,
6566 ) . toThrowErrorMatchingSnapshot ( ) ;
6667} ) ;
@@ -76,6 +77,58 @@ test('omits null and undefined config values', () => {
7677 } ) ;
7778} ) ;
7879
80+ test ( 'recursively omits null and undefined config values' , ( ) => {
81+ const config = {
82+ haste : {
83+ providesModuleNodeModules : null ,
84+ } ,
85+ } ;
86+ expect (
87+ validate ( config , { exampleConfig : validConfig , recursive : true } ) ,
88+ ) . toEqual ( {
89+ hasDeprecationWarnings : false ,
90+ isValid : true ,
91+ } ) ;
92+ } ) ;
93+
94+ test ( 'respects blacklist' , ( ) => {
95+ const warn = console . warn ;
96+ console . warn = jest . fn ( ) ;
97+ const config = {
98+ something : {
99+ nested : {
100+ some_random_key : 'value' ,
101+ some_random_key2 : 'value2' ,
102+ } ,
103+ } ,
104+ } ;
105+ const exampleConfig = {
106+ something : {
107+ nested : {
108+ test : true ,
109+ } ,
110+ } ,
111+ } ;
112+
113+ validate ( config , {
114+ exampleConfig,
115+ recursive : true ,
116+ } ) ;
117+
118+ expect ( console . warn ) . toBeCalled ( ) ;
119+
120+ console . warn . mockReset ( ) ;
121+
122+ validate ( config , {
123+ blacklist : [ 'something.nested' ] ,
124+ exampleConfig,
125+ recursive : true ,
126+ } ) ;
127+
128+ expect ( console . warn ) . not . toBeCalled ( ) ;
129+ console . warn = warn ;
130+ } ) ;
131+
79132test ( 'displays warning for unknown config options' , ( ) => {
80133 const config = { unkwon : { } } ;
81134 const validConfig = { unknown : 'string' } ;
@@ -97,6 +150,7 @@ test('displays warning for deprecated config options', () => {
97150 validate ( config , {
98151 deprecatedConfig,
99152 exampleConfig : validConfig ,
153+ recursive : true ,
100154 } ) ,
101155 ) . toEqual ( {
102156 hasDeprecationWarnings : true ,
0 commit comments