@@ -367,6 +367,80 @@ describe('the nyc cli', function () {
367
367
} )
368
368
} )
369
369
370
+ describe ( 'nyc.config.js' , function ( ) {
371
+ var cwd = path . resolve ( fixturesCLI , './nyc-config-js' )
372
+
373
+ it ( 'loads configuration from package.json and nyc.config.js' , function ( done ) {
374
+ var args = [ bin , process . execPath , './index.js' ]
375
+
376
+ var proc = spawn ( process . execPath , args , {
377
+ cwd : cwd ,
378
+ env : env
379
+ } )
380
+
381
+ var stdout = ''
382
+ proc . stdout . on ( 'data' , function ( chunk ) {
383
+ stdout += chunk
384
+ } )
385
+
386
+ proc . on ( 'close' , function ( code ) {
387
+ code . should . equal ( 0 )
388
+ stdout . should . match ( / S F : .* i n d e x \. j s / )
389
+ stdout . should . not . match ( / S F : .* i g n o r e \. j s / )
390
+ stdout . should . not . match ( / S F : .* n y c \. c o n f i g \. j s / )
391
+ stdout . should . not . match ( / S F : .* n y c r c - c o n f i g \. j s / )
392
+ done ( )
393
+ } )
394
+ } )
395
+
396
+ it ( 'loads configuration from different module rather than nyc.config.js' , function ( done ) {
397
+ var args = [ bin , '--all' , '--nycrc-path' , './nycrc-config.js' , process . execPath , './index.js' ]
398
+
399
+ var proc = spawn ( process . execPath , args , {
400
+ cwd : cwd ,
401
+ env : env
402
+ } )
403
+
404
+ var stdout = ''
405
+ proc . stdout . on ( 'data' , function ( chunk ) {
406
+ stdout += chunk
407
+ } )
408
+
409
+ proc . on ( 'close' , function ( code ) {
410
+ // should be 1 due to coverage check
411
+ code . should . equal ( 1 )
412
+ stdout . should . match ( / S F : .* i n d e x \. j s / )
413
+ stdout . should . match ( / S F : .* i g n o r e \. j s / )
414
+ stdout . should . match ( / S F : .* n y c \. c o n f i g \. j s / )
415
+ stdout . should . match ( / S F : .* n y c r c - c o n f i g \. j s / )
416
+ done ( )
417
+ } )
418
+ } )
419
+
420
+ it ( 'allows nyc.config.js configuration to be overridden with command line args' , function ( done ) {
421
+ var args = [ bin , '--all' , '--exclude=foo.js' , process . execPath , './index.js' ]
422
+
423
+ var proc = spawn ( process . execPath , args , {
424
+ cwd : cwd ,
425
+ env : env
426
+ } )
427
+
428
+ var stdout = ''
429
+ proc . stdout . on ( 'data' , function ( chunk ) {
430
+ stdout += chunk
431
+ } )
432
+
433
+ proc . on ( 'close' , function ( code ) {
434
+ code . should . equal ( 0 )
435
+ stdout . should . match ( / S F : .* i n d e x \. j s / )
436
+ stdout . should . match ( / S F : .* i g n o r e \. j s / )
437
+ stdout . should . match ( / S F : .* n y c \. c o n f i g \. j s / )
438
+ stdout . should . match ( / S F : .* n y c r c - c o n f i g \. j s / )
439
+ done ( )
440
+ } )
441
+ } )
442
+ } )
443
+
370
444
describe ( '.nycrc' , function ( ) {
371
445
var cwd = path . resolve ( fixturesCLI , './nycrc' )
372
446
0 commit comments