@@ -281,53 +281,88 @@ function sharedRunnerBehaviors(makeRunner) {
281
281
await expectAsync ( this . fixtureJasmine . loadConfigFile ( ) ) . toBeResolved ( ) ;
282
282
} ) ;
283
283
284
- it ( 'loads the default .json configuration file' , async function ( ) {
285
- await this . fixtureJasmine . loadConfigFile ( ) ;
286
- expect ( this . fixtureJasmine . specFiles ) . toEqual ( [
287
- pathEndingWith ( 'spec/fixtures/sample_project/spec/fixture_spec.js' )
288
- ] ) ;
289
- } ) ;
290
-
291
- it ( 'loads the default .js configuration file' , async function ( ) {
292
- const config = require ( './fixtures/sample_project/spec/support/jasmine.json' ) ;
293
- spyOn ( Loader . prototype , 'load' ) . and . callFake ( function ( path ) {
294
- if ( path . endsWith ( 'jasmine.js' ) ) {
295
- return Promise . resolve ( config ) ;
296
- } else {
297
- const e = new Error ( `Module not found: ${ path } ` ) ;
298
- e . code = 'MODULE_NOT_FOUND' ;
299
- return Promise . reject ( e ) ;
300
- }
284
+ describe ( 'When the default .mjs configuration file exists' , function ( ) {
285
+ it ( 'loads the default .mjs configuration file' , async function ( ) {
286
+ const config = require ( './fixtures/sample_project/spec/support/jasmine.json' ) ;
287
+ spyOn ( Loader . prototype , 'load' )
288
+ . withArgs ( jasmine . stringMatching ( / j a s m i n e \. m j s $ / ) )
289
+ . and . returnValue ( Promise . resolve ( config ) ) ;
290
+
291
+ await this . fixtureJasmine . loadConfigFile ( ) ;
292
+
293
+ expect ( Loader . prototype . load ) . toHaveBeenCalledWith ( jasmine . stringMatching (
294
+ 'jasmine\.mjs$'
295
+ ) ) ;
296
+ expect ( this . fixtureJasmine . specFiles ) . toEqual ( [
297
+ pathEndingWith ( 'spec/fixtures/sample_project/spec/fixture_spec.js' )
298
+ ] ) ;
301
299
} ) ;
302
300
303
- await this . fixtureJasmine . loadConfigFile ( ) ;
304
- expect ( Loader . prototype . load ) . toHaveBeenCalledWith ( jasmine . stringMatching (
305
- 'jasmine\.js$'
306
- ) ) ;
307
- expect ( this . fixtureJasmine . specFiles ) . toEqual ( [
308
- pathEndingWith ( 'spec/fixtures/sample_project/spec/fixture_spec.js' )
309
- ] ) ;
301
+ it ( 'does not also load the default .js or .json configuration files' , async function ( ) {
302
+ spyOn ( Loader . prototype , 'load' )
303
+ . withArgs ( jasmine . stringMatching ( / j a s m i n e \. m j s $ / ) )
304
+ . and . returnValue ( Promise . resolve ( { } ) ) ;
305
+
306
+ await this . fixtureJasmine . loadConfigFile ( ) ;
307
+
308
+ expect ( Loader . prototype . load ) . not . toHaveBeenCalledWith ( jasmine . stringMatching (
309
+ 'jasmine\.js$'
310
+ ) ) ;
311
+ expect ( Loader . prototype . load ) . not . toHaveBeenCalledWith ( jasmine . stringMatching (
312
+ 'jasmine\.json$'
313
+ ) ) ;
314
+ } ) ;
310
315
} ) ;
311
316
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
- }
317
+ describe ( 'When the default .mjs configuration file does not exist' , function ( ) {
318
+ it ( 'loads the default .json configuration file' , async function ( ) {
319
+ await this . fixtureJasmine . loadConfigFile ( ) ;
320
+ expect ( this . fixtureJasmine . specFiles ) . toEqual ( [
321
+ pathEndingWith ( 'spec/fixtures/sample_project/spec/fixture_spec.js' )
322
+ ] ) ;
321
323
} ) ;
322
- spyOn ( console , 'warn' ) ;
323
324
324
- await this . fixtureJasmine . loadConfigFile ( ) ;
325
+ it ( 'loads the default .js configuration file' , async function ( ) {
326
+ const config = require ( './fixtures/sample_project/spec/support/jasmine.json' ) ;
327
+ spyOn ( Loader . prototype , 'load' ) . and . callFake ( function ( path ) {
328
+ if ( path . endsWith ( 'jasmine.js' ) ) {
329
+ return Promise . resolve ( config ) ;
330
+ } else {
331
+ const e = new Error ( `Module not found: ${ path } ` ) ;
332
+ e . code = 'MODULE_NOT_FOUND' ;
333
+ return Promise . reject ( e ) ;
334
+ }
335
+ } ) ;
336
+
337
+ await this . fixtureJasmine . loadConfigFile ( ) ;
338
+ expect ( Loader . prototype . load ) . toHaveBeenCalledWith ( jasmine . stringMatching (
339
+ 'jasmine\.js$'
340
+ ) ) ;
341
+ expect ( this . fixtureJasmine . specFiles ) . toEqual ( [
342
+ pathEndingWith ( 'spec/fixtures/sample_project/spec/fixture_spec.js' )
343
+ ] ) ;
344
+ } ) ;
325
345
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
- ) ;
346
+ it ( 'warns if default .js and .json config files are both found' , async function ( ) {
347
+ spyOn ( Loader . prototype , 'load' ) . and . callFake ( function ( path ) {
348
+ if ( path . endsWith ( 'jasmine.js' ) || path . endsWith ( 'jasmine.json' ) ) {
349
+ return Promise . resolve ( { } ) ;
350
+ } else {
351
+ const e = new Error ( `Module not found: ${ path } ` ) ;
352
+ e . code = 'MODULE_NOT_FOUND' ;
353
+ return Promise . reject ( e ) ;
354
+ }
355
+ } ) ;
356
+ spyOn ( console , 'warn' ) ;
357
+
358
+ await this . fixtureJasmine . loadConfigFile ( ) ;
359
+
360
+ expect ( console . warn ) . toHaveBeenCalledWith (
361
+ 'Deprecation warning: Jasmine found and loaded both jasmine.js ' +
362
+ 'and jasmine.json\nconfig files. In a future version, only the ' +
363
+ 'first file found will be loaded.'
364
+ ) ;
365
+ } ) ;
331
366
} ) ;
332
367
} ) ;
333
368
} ) ;
0 commit comments