Skip to content

Commit 0b4b95b

Browse files
committed
feat(prelude): use relative paths to identify instrumented files
Full paths are too verbose and unnecessary.
1 parent 0e81324 commit 0b4b95b

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/prelude.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const defaultNamespace = '__coverage__';
1111

1212
export default function prelude(state) {
1313
const {variable, locations} = getCoverageMeta(state);
14-
const name = state.file.opts.filenameRelative;
14+
const name = state.file.opts.filenameRelative.replace(`${process.cwd()}${path.sep}`, '');
1515
const namespace = state.opts && state.opts.global || defaultNamespace;
1616
return render({
1717
VARIABLE: variable,

test/spec/helpers/run.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {defaultNamespace as namespace} from '../../../src/prelude';
66

77
export default function runFixture(fixtureName) {
88
const fixturePath = path.resolve(__dirname, `../../fixture/${fixtureName}.fixture.js`);
9+
const relativeFixturePath = fixturePath.replace(`${process.cwd()}${path.sep}`, '');
910
return transform(fixturePath)
1011
.then(({code}) => {
1112
const sandbox = {
@@ -14,7 +15,7 @@ export default function runFixture(fixtureName) {
1415
exports: {}
1516
};
1617
runInNewContext(code, sandbox);
17-
const fileCoverage = sandbox.global[namespace][fixturePath];
18+
const fileCoverage = sandbox.global[namespace][relativeFixturePath];
1819
return codec.decodeAll(fileCoverage);
1920
})
2021
.catch(error => console.error(error)); // eslint-disable-line no-console

0 commit comments

Comments
 (0)