File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -78,9 +78,12 @@ class RunnerBase {
7878 if ( configFilePath ) {
7979 await this . loadSpecificConfigFile_ ( configFilePath ) ;
8080 } else {
81+ let numFound = 0 ;
82+
8183 for ( const ext of [ 'json' , 'js' ] ) {
8284 try {
8385 await this . loadSpecificConfigFile_ ( `spec/support/jasmine.${ ext } ` ) ;
86+ numFound ++ ;
8487 } catch ( e ) {
8588 if ( e . code !== 'MODULE_NOT_FOUND' // CommonJS
8689 && e . code !== 'ERR_MODULE_NOT_FOUND' // ESM
@@ -89,6 +92,15 @@ class RunnerBase {
8992 }
9093 }
9194 }
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+ }
92104 }
93105 }
94106
Original file line number Diff line number Diff line change @@ -308,6 +308,27 @@ function sharedRunnerBehaviors(makeRunner) {
308308 pathEndingWith ( 'spec/fixtures/sample_project/spec/fixture_spec.js' )
309309 ] ) ;
310310 } ) ;
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+ } ) ;
311332 } ) ;
312333 } ) ;
313334
You can’t perform that action at this time.
0 commit comments