File tree 2 files changed +38
-5
lines changed
2 files changed +38
-5
lines changed Original file line number Diff line number Diff line change @@ -415,22 +415,22 @@ function coverageFinder () {
415
415
}
416
416
417
417
NYC . prototype . getCoverageMapFromAllCoverageFiles = function ( baseDirectory ) {
418
- var _this = this
419
418
var map = libCoverage . createCoverageMap ( { } )
420
419
421
420
this . eachReport ( undefined , ( report ) => {
422
421
map . merge ( report )
423
422
} , baseDirectory )
423
+
424
+ map . data = this . sourceMaps . remapCoverage ( map . data )
425
+
424
426
// depending on whether source-code is pre-instrumented
425
427
// or instrumented using a JIT plugin like @babel /require
426
428
// you may opt to exclude files after applying
427
429
// source-map remapping logic.
428
430
if ( this . config . excludeAfterRemap ) {
429
- map . filter ( function ( filename ) {
430
- return _this . exclude . shouldInstrument ( filename )
431
- } )
431
+ map . filter ( filename => this . exclude . shouldInstrument ( filename ) )
432
432
}
433
- map . data = this . sourceMaps . remapCoverage ( map . data )
433
+
434
434
return map
435
435
}
436
436
Original file line number Diff line number Diff line change @@ -1043,6 +1043,39 @@ describe('the nyc cli', function () {
1043
1043
done ( )
1044
1044
} )
1045
1045
} )
1046
+
1047
+ it ( 'uses source-maps to exclude original sources from reports' , ( done ) => {
1048
+ const args = [
1049
+ bin ,
1050
+ '--all' ,
1051
+ '--cache' , 'false' ,
1052
+ '--exclude' , 'original/s1.js' ,
1053
+ process . execPath , './instrumented/s1.min.js'
1054
+ ]
1055
+
1056
+ const proc = spawn ( process . execPath , args , {
1057
+ cwd : fixturesSourceMaps ,
1058
+ env : env
1059
+ } )
1060
+
1061
+ var stdout = ''
1062
+ proc . stdout . on ( 'data' , function ( chunk ) {
1063
+ stdout += chunk
1064
+ } )
1065
+
1066
+ proc . on ( 'close' , function ( code ) {
1067
+ code . should . equal ( 0 )
1068
+ stdoutShouldEqual ( stdout , `
1069
+ ----------|----------|----------|----------|----------|-------------------|
1070
+ File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
1071
+ ----------|----------|----------|----------|----------|-------------------|
1072
+ All files | 0 | 100 | 0 | 0 | |
1073
+ s2.js | 0 | 100 | 0 | 0 | 1,2,4,6 |
1074
+ ----------|----------|----------|----------|----------|-------------------|`
1075
+ )
1076
+ done ( )
1077
+ } )
1078
+ } )
1046
1079
} )
1047
1080
1048
1081
describe ( '.map file' , ( ) => {
You can’t perform that action at this time.
0 commit comments