File tree Expand file tree Collapse file tree 2 files changed +42
-6
lines changed Expand file tree Collapse file tree 2 files changed +42
-6
lines changed Original file line number Diff line number Diff line change 11// @ts -check
2+ function stringToArray ( prop , obj ) {
3+ if ( typeof obj [ prop ] === 'string' ) {
4+ obj [ prop ] = [ obj [ prop ] ]
5+ }
6+
7+ return obj
8+ }
9+
210function combineNycOptions ( {
311 pkgNycOptions,
412 nycrc,
@@ -14,12 +22,10 @@ function combineNycOptions({
1422 pkgNycOptions
1523 )
1624
17- if ( typeof nycOptions . reporter === 'string' ) {
18- nycOptions . reporter = [ nycOptions . reporter ]
19- }
20- if ( typeof nycOptions . extension === 'string' ) {
21- nycOptions . extension = [ nycOptions . extension ]
22- }
25+ // normalize string and [string] props
26+ stringToArray ( 'reporter' , nycOptions )
27+ stringToArray ( 'extension' , nycOptions )
28+ stringToArray ( 'exclude' , nycOptions )
2329
2430 return nycOptions
2531}
Original file line number Diff line number Diff line change @@ -63,4 +63,34 @@ describe('Combine NYC options', () => {
6363 exclude : [ 'bar.js' ]
6464 } )
6565 } )
66+
67+ it ( 'converts exclude to array' , ( ) => {
68+ // https://github.com/cypress-io/code-coverage/issues/248
69+ const pkgNycOptions = {
70+ all : true ,
71+ extension : '.js'
72+ }
73+ const nycrc = {
74+ include : [ 'foo.js' ]
75+ }
76+ const nycrcJson = {
77+ exclude : 'bar.js' ,
78+ reporter : [ 'json' ]
79+ }
80+ const combined = combineNycOptions ( {
81+ pkgNycOptions,
82+ nycrc,
83+ nycrcJson,
84+ defaultNycOptions
85+ } )
86+ cy . wrap ( combined ) . should ( 'deep.equal' , {
87+ all : true ,
88+ 'report-dir' : './coverage' ,
89+ reporter : [ 'json' ] ,
90+ extension : [ '.js' ] ,
91+ excludeAfterRemap : false ,
92+ include : [ 'foo.js' ] ,
93+ exclude : [ 'bar.js' ]
94+ } )
95+ } )
6696} )
You can’t perform that action at this time.
0 commit comments