@@ -59,18 +59,18 @@ beforeEach(async () => {
59
59
60
60
afterEach ( ( ) => cleanup ( DIR ) ) ;
61
61
62
- test ( 'should have a valid structure by default' , ( ) => {
62
+ test ( 'should have a valid structure by default' , async ( ) => {
63
63
DIR = getTempDirectory ( 'config_test_structure' ) ;
64
64
writeFiles ( DIR , {
65
65
'react-native.config.js' : `module.exports = {
66
66
reactNativePath: "."
67
67
}` ,
68
68
} ) ;
69
- const config = loadConfig ( { projectRoot : DIR } ) ;
69
+ const config = await loadConfig ( { projectRoot : DIR } ) ;
70
70
expect ( removeString ( config , DIR ) ) . toMatchSnapshot ( ) ;
71
71
} ) ;
72
72
73
- test ( 'should return dependencies from package.json' , ( ) => {
73
+ test ( 'should return dependencies from package.json' , async ( ) => {
74
74
DIR = getTempDirectory ( 'config_test_deps' ) ;
75
75
writeFiles ( DIR , {
76
76
...REACT_NATIVE_MOCK ,
@@ -83,11 +83,11 @@ test('should return dependencies from package.json', () => {
83
83
}
84
84
}` ,
85
85
} ) ;
86
- const { dependencies} = loadConfig ( { projectRoot : DIR } ) ;
86
+ const { dependencies} = await loadConfig ( { projectRoot : DIR } ) ;
87
87
expect ( removeString ( dependencies , DIR ) ) . toMatchSnapshot ( ) ;
88
88
} ) ;
89
89
90
- test ( 'should read a config of a dependency and use it to load other settings' , ( ) => {
90
+ test ( 'should read a config of a dependency and use it to load other settings' , async ( ) => {
91
91
DIR = getTempDirectory ( 'config_test_settings' ) ;
92
92
writeFiles ( DIR , {
93
93
...REACT_NATIVE_MOCK ,
@@ -122,13 +122,13 @@ test('should read a config of a dependency and use it to load other settings', (
122
122
}
123
123
}` ,
124
124
} ) ;
125
- const { dependencies} = loadConfig ( { projectRoot : DIR } ) ;
125
+ const { dependencies} = await loadConfig ( { projectRoot : DIR } ) ;
126
126
expect (
127
127
removeString ( dependencies [ 'react-native-test' ] , DIR ) ,
128
128
) . toMatchSnapshot ( ) ;
129
129
} ) ;
130
130
131
- test ( 'command specified in root config should overwrite command in "react-native-foo" and "react-native-bar" packages' , ( ) => {
131
+ test ( 'command specified in root config should overwrite command in "react-native-foo" and "react-native-bar" packages' , async ( ) => {
132
132
DIR = getTempDirectory ( 'config_test_packages' ) ;
133
133
writeFiles ( DIR , {
134
134
'node_modules/react-native-foo/package.json' : '{}' ,
@@ -173,15 +173,15 @@ test('command specified in root config should overwrite command in "react-native
173
173
],
174
174
};` ,
175
175
} ) ;
176
- const { commands} = loadConfig ( { projectRoot : DIR } ) ;
176
+ const { commands} = await loadConfig ( { projectRoot : DIR } ) ;
177
177
const commandsNames = commands . map ( ( { name} ) => name ) ;
178
178
const commandIndex = commandsNames . indexOf ( 'foo-command' ) ;
179
179
180
180
expect ( commands [ commandIndex ] . options ) . not . toBeNull ( ) ;
181
181
expect ( commands [ commandIndex ] ) . toMatchSnapshot ( ) ;
182
182
} ) ;
183
183
184
- test ( 'should merge project configuration with default values' , ( ) => {
184
+ test ( 'should merge project configuration with default values' , async ( ) => {
185
185
DIR = getTempDirectory ( 'config_test_merge' ) ;
186
186
writeFiles ( DIR , {
187
187
...REACT_NATIVE_MOCK ,
@@ -206,13 +206,13 @@ test('should merge project configuration with default values', () => {
206
206
}
207
207
}` ,
208
208
} ) ;
209
- const { dependencies} = loadConfig ( { projectRoot : DIR } ) ;
209
+ const { dependencies} = await loadConfig ( { projectRoot : DIR } ) ;
210
210
expect ( removeString ( dependencies [ 'react-native-test' ] , DIR ) ) . toMatchSnapshot (
211
211
'snapshoting `react-native-test` config' ,
212
212
) ;
213
213
} ) ;
214
214
215
- test ( 'should load commands from "react-native-foo" and "react-native-bar" packages' , ( ) => {
215
+ test ( 'should load commands from "react-native-foo" and "react-native-bar" packages' , async ( ) => {
216
216
DIR = getTempDirectory ( 'config_test_packages' ) ;
217
217
writeFiles ( DIR , {
218
218
'react-native.config.js' : 'module.exports = { reactNativePath: "." }' ,
@@ -241,11 +241,11 @@ test('should load commands from "react-native-foo" and "react-native-bar" packag
241
241
}
242
242
}` ,
243
243
} ) ;
244
- const { commands} = loadConfig ( { projectRoot : DIR } ) ;
244
+ const { commands} = await loadConfig ( { projectRoot : DIR } ) ;
245
245
expect ( commands ) . toMatchSnapshot ( ) ;
246
246
} ) ;
247
247
248
- test ( 'should not skip packages that have invalid configuration (to avoid breaking users)' , ( ) => {
248
+ test ( 'should not skip packages that have invalid configuration (to avoid breaking users)' , async ( ) => {
249
249
process . env . FORCE_COLOR = '0' ; // To disable chalk
250
250
DIR = getTempDirectory ( 'config_test_skip' ) ;
251
251
writeFiles ( DIR , {
@@ -261,14 +261,14 @@ test('should not skip packages that have invalid configuration (to avoid breakin
261
261
}
262
262
}` ,
263
263
} ) ;
264
- const { dependencies} = loadConfig ( { projectRoot : DIR } ) ;
264
+ const { dependencies} = await loadConfig ( { projectRoot : DIR } ) ;
265
265
expect ( removeString ( dependencies , DIR ) ) . toMatchSnapshot (
266
266
'dependencies config' ,
267
267
) ;
268
268
expect ( spy . mock . calls [ 0 ] [ 0 ] ) . toMatchSnapshot ( 'logged warning' ) ;
269
269
} ) ;
270
270
271
- test ( 'does not use restricted "react-native" key to resolve config from package.json' , ( ) => {
271
+ test ( 'does not use restricted "react-native" key to resolve config from package.json' , async ( ) => {
272
272
DIR = getTempDirectory ( 'config_test_restricted' ) ;
273
273
writeFiles ( DIR , {
274
274
'node_modules/react-native-netinfo/package.json' : `{
@@ -281,12 +281,12 @@ test('does not use restricted "react-native" key to resolve config from package.
281
281
}
282
282
}` ,
283
283
} ) ;
284
- const { dependencies} = loadConfig ( { projectRoot : DIR } ) ;
284
+ const { dependencies} = await loadConfig ( { projectRoot : DIR } ) ;
285
285
expect ( dependencies ) . toHaveProperty ( 'react-native-netinfo' ) ;
286
286
expect ( spy ) . not . toHaveBeenCalled ( ) ;
287
287
} ) ;
288
288
289
- test ( 'supports dependencies from user configuration with custom root and properties' , ( ) => {
289
+ test ( 'supports dependencies from user configuration with custom root and properties' , async ( ) => {
290
290
DIR = getTempDirectory ( 'config_test_custom_root' ) ;
291
291
const escapePathSeparator = ( value : string ) =>
292
292
path . sep === '\\' ? value . replace ( / ( \/ | \\ ) / g, '\\\\' ) : value ;
@@ -327,7 +327,7 @@ module.exports = {
327
327
}` ,
328
328
} ) ;
329
329
330
- const { dependencies} = loadConfig ( { projectRoot : DIR } ) ;
330
+ const { dependencies} = await loadConfig ( { projectRoot : DIR } ) ;
331
331
expect ( removeString ( dependencies [ 'local-lib' ] , DIR ) ) . toMatchInlineSnapshot ( `
332
332
Object {
333
333
"name": "local-lib",
@@ -345,7 +345,7 @@ module.exports = {
345
345
` ) ;
346
346
} ) ;
347
347
348
- test ( 'should apply build types from dependency config' , ( ) => {
348
+ test ( 'should apply build types from dependency config' , async ( ) => {
349
349
DIR = getTempDirectory ( 'config_test_apply_dependency_config' ) ;
350
350
writeFiles ( DIR , {
351
351
...REACT_NATIVE_MOCK ,
@@ -367,13 +367,13 @@ test('should apply build types from dependency config', () => {
367
367
}
368
368
}` ,
369
369
} ) ;
370
- const { dependencies} = loadConfig ( { projectRoot : DIR } ) ;
370
+ const { dependencies} = await loadConfig ( { projectRoot : DIR } ) ;
371
371
expect (
372
372
removeString ( dependencies [ 'react-native-test' ] , DIR ) ,
373
373
) . toMatchSnapshot ( ) ;
374
374
} ) ;
375
375
376
- test ( 'supports dependencies from user configuration with custom build type' , ( ) => {
376
+ test ( 'supports dependencies from user configuration with custom build type' , async ( ) => {
377
377
DIR = getTempDirectory ( 'config_test_apply_custom_build_config' ) ;
378
378
writeFiles ( DIR , {
379
379
...REACT_NATIVE_MOCK ,
@@ -400,13 +400,13 @@ test('supports dependencies from user configuration with custom build type', ()
400
400
}` ,
401
401
} ) ;
402
402
403
- const { dependencies} = loadConfig ( { projectRoot : DIR } ) ;
403
+ const { dependencies} = await loadConfig ( { projectRoot : DIR } ) ;
404
404
expect (
405
405
removeString ( dependencies [ 'react-native-test' ] , DIR ) ,
406
406
) . toMatchSnapshot ( ) ;
407
407
} ) ;
408
408
409
- test ( 'supports disabling dependency for ios platform' , ( ) => {
409
+ test ( 'supports disabling dependency for ios platform' , async ( ) => {
410
410
DIR = getTempDirectory ( 'config_test_disable_dependency_platform' ) ;
411
411
writeFiles ( DIR , {
412
412
...REACT_NATIVE_MOCK ,
@@ -429,13 +429,13 @@ test('supports disabling dependency for ios platform', () => {
429
429
}` ,
430
430
} ) ;
431
431
432
- const { dependencies} = loadConfig ( { projectRoot : DIR } ) ;
432
+ const { dependencies} = await loadConfig ( { projectRoot : DIR } ) ;
433
433
expect (
434
434
removeString ( dependencies [ 'react-native-test' ] , DIR ) ,
435
435
) . toMatchSnapshot ( ) ;
436
436
} ) ;
437
437
438
- test ( 'should convert project sourceDir relative path to absolute' , ( ) => {
438
+ test ( 'should convert project sourceDir relative path to absolute' , async ( ) => {
439
439
DIR = getTempDirectory ( 'config_test_absolute_project_source_dir' ) ;
440
440
const iosProjectDir = './ios2' ;
441
441
const androidProjectDir = './android2' ;
@@ -494,7 +494,7 @@ test('should convert project sourceDir relative path to absolute', () => {
494
494
` ,
495
495
} ) ;
496
496
497
- const config = loadConfig ( { projectRoot : DIR } ) ;
497
+ const config = await loadConfig ( { projectRoot : DIR } ) ;
498
498
499
499
expect ( config . project . ios ?. sourceDir ) . toBe ( path . join ( DIR , iosProjectDir ) ) ;
500
500
expect ( config . project . android ?. sourceDir ) . toBe (
0 commit comments