Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Populate lastFileCoverage for already instrumented files (#470)
Fixes istanbuljs/nyc#594
- Loading branch information
1 parent
a629770
commit ea6d779
Showing
7 changed files
with
79 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
export default function defaultOpts() { | ||
return { | ||
coverageVariable: '__coverage__', | ||
coverageGlobalScope: 'this', | ||
coverageGlobalScopeFunc: true, | ||
preserveComments: false, | ||
compact: true, | ||
esModules: false, | ||
autoWrap: false, | ||
produceSourceMap: false, | ||
ignoreClassMethods: [], | ||
sourceMapUrlCallback: null, | ||
debug: false, | ||
/* babel parser plugins are to be enabled when the feature is stage 3 and | ||
* implemented in a released version of node.js */ | ||
plugins: [ | ||
'asyncGenerators', | ||
'bigInt', | ||
'classProperties', | ||
'classPrivateProperties', | ||
'dynamicImport', | ||
'importMeta', | ||
'objectRestSpread', | ||
'optionalCatchBinding', | ||
'flow', | ||
'jsx' | ||
] | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
packages/istanbul-lib-instrument/test/already-instrumented.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* globals it */ | ||
|
||
import { assert } from 'chai'; | ||
import Instrumenter from '../src/instrumenter'; | ||
|
||
function instrument(code) { | ||
const instrumenter = new Instrumenter({}); | ||
const result = instrumenter.instrumentSync(code, __filename); | ||
return { | ||
code: result, | ||
coverageData: instrumenter.lastFileCoverage(), | ||
sourceMap: instrumenter.lastSourceMap() | ||
}; | ||
} | ||
|
||
const instrumented = instrument(`console.log('basic test');`); | ||
|
||
it('should not alter already instrumented code', () => { | ||
const result = instrument(instrumented.code); | ||
assert.deepEqual(instrumented, result); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters