File tree 2 files changed +33
-0
lines changed
2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -78,9 +78,12 @@ class RunnerBase {
78
78
if ( configFilePath ) {
79
79
await this . loadSpecificConfigFile_ ( configFilePath ) ;
80
80
} else {
81
+ let numFound = 0 ;
82
+
81
83
for ( const ext of [ 'json' , 'js' ] ) {
82
84
try {
83
85
await this . loadSpecificConfigFile_ ( `spec/support/jasmine.${ ext } ` ) ;
86
+ numFound ++ ;
84
87
} catch ( e ) {
85
88
if ( e . code !== 'MODULE_NOT_FOUND' // CommonJS
86
89
&& e . code !== 'ERR_MODULE_NOT_FOUND' // ESM
@@ -89,6 +92,15 @@ class RunnerBase {
89
92
}
90
93
}
91
94
}
95
+
96
+ if ( numFound > 1 ) {
97
+ console . warn (
98
+ 'Deprecation warning: Jasmine found and loaded both jasmine.js ' +
99
+ 'and jasmine.json\n' +
100
+ 'config files. In a future version, only the first file found ' +
101
+ 'will be loaded.'
102
+ ) ;
103
+ }
92
104
}
93
105
}
94
106
Original file line number Diff line number Diff line change @@ -308,6 +308,27 @@ function sharedRunnerBehaviors(makeRunner) {
308
308
pathEndingWith ( 'spec/fixtures/sample_project/spec/fixture_spec.js' )
309
309
] ) ;
310
310
} ) ;
311
+
312
+ it ( 'warns if both default config files are found' , async function ( ) {
313
+ spyOn ( Loader . prototype , 'load' ) . and . callFake ( function ( path ) {
314
+ if ( path . endsWith ( 'jasmine.js' ) || path . endsWith ( 'jasmine.json' ) ) {
315
+ return Promise . resolve ( { } ) ;
316
+ } else {
317
+ const e = new Error ( `Module not found: ${ path } ` ) ;
318
+ e . code = 'MODULE_NOT_FOUND' ;
319
+ return Promise . reject ( e ) ;
320
+ }
321
+ } ) ;
322
+ spyOn ( console , 'warn' ) ;
323
+
324
+ await this . fixtureJasmine . loadConfigFile ( ) ;
325
+
326
+ expect ( console . warn ) . toHaveBeenCalledWith (
327
+ 'Deprecation warning: Jasmine found and loaded both jasmine.js ' +
328
+ 'and jasmine.json\nconfig files. In a future version, only the ' +
329
+ 'first file found will be loaded.'
330
+ ) ;
331
+ } ) ;
311
332
} ) ;
312
333
} ) ;
313
334
You can’t perform that action at this time.
0 commit comments