Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use v8-to-istanbul without source-map #12697

Merged
merged 6 commits into from Apr 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -89,6 +89,7 @@
- `[jest-mock]` Handle overridden `Function.name` property ([#12674](https://github.com/facebook/jest/pull/12674))
- `[@jest/reporters]` Notifications generated by the `--notify` flag are no longer persistent in GNOME Shell. ([#11733](https://github.com/facebook/jest/pull/11733))
- `[@jest/reporters]` Move missing icon file which is needed for `NotifyReporter` class. ([#12593](https://github.com/facebook/jest/pull/12593))
- `[@jest/reporters]` Update `v8-to-istanbul` ([#12697](https://github.com/facebook/jest/pull/12697))
- `[jest-resolver]` Call custom resolver with core node.js modules ([#12654](https://github.com/facebook/jest/pull/12654))
- `[jest-worker]` Fix `Farm` execution results memory leak ([#12497](https://github.com/facebook/jest/pull/12497))

Expand Down
16 changes: 6 additions & 10 deletions e2e/__tests__/coverageProviderV8.test.ts
Expand Up @@ -11,17 +11,13 @@ import runJest from '../runJest';

const DIR = path.resolve(__dirname, '../coverage-provider-v8');

// https://github.com/nodejs/node/issues/42638
const nodeOptions =
typeof fetch === 'undefined' ? '' : '--no-experimental-fetch';

test('prints coverage with missing sourcemaps', () => {
const sourcemapDir = path.join(DIR, 'no-sourcemap');

const {stdout, exitCode} = runJest(
sourcemapDir,
['--coverage', '--coverage-provider', 'v8'],
{nodeOptions, stripAnsi: true},
{stripAnsi: true},
);

expect(exitCode).toBe(0);
Expand All @@ -34,7 +30,7 @@ test('prints coverage with empty sourcemaps', () => {
const {stdout, exitCode} = runJest(
sourcemapDir,
['--coverage', '--coverage-provider', 'v8'],
{nodeOptions, stripAnsi: true},
{stripAnsi: true},
);

expect(exitCode).toBe(0);
Expand All @@ -47,7 +43,7 @@ test('prints correct coverage report, if a CJS module is put under test without
const {stdout, exitCode} = runJest(
sourcemapDir,
['--coverage', '--coverage-provider', 'v8', '--no-cache'],
{nodeOptions, stripAnsi: true},
{stripAnsi: true},
);

expect(exitCode).toBe(0);
Expand All @@ -60,7 +56,7 @@ test('prints correct coverage report, if a TS module is transpiled by Babel to C
const {stdout, exitCode} = runJest(
sourcemapDir,
['--coverage', '--coverage-provider', 'v8', '--no-cache'],
{nodeOptions, stripAnsi: true},
{stripAnsi: true},
);

expect(exitCode).toBe(0);
Expand All @@ -76,7 +72,7 @@ onNodeVersions('>=12.16.0', () => {
sourcemapDir,
['--coverage', '--coverage-provider', 'v8', '--no-cache'],
{
nodeOptions: `${nodeOptions} --experimental-vm-modules --no-warnings`,
nodeOptions: '--experimental-vm-modules --no-warnings',
stripAnsi: true,
},
);
Expand All @@ -92,7 +88,7 @@ onNodeVersions('>=12.16.0', () => {
sourcemapDir,
['--coverage', '--coverage-provider', 'v8', '--no-cache'],
{
nodeOptions: `${nodeOptions} --experimental-vm-modules --no-warnings`,
nodeOptions: '--experimental-vm-modules --no-warnings',
stripAnsi: true,
},
);
Expand Down
4 changes: 2 additions & 2 deletions packages/jest-reporters/package.json
Expand Up @@ -17,7 +17,7 @@
"@jest/test-result": "^28.0.0-alpha.9",
"@jest/transform": "^28.0.0-alpha.10",
"@jest/types": "^28.0.0-alpha.9",
"@jridgewell/trace-mapping": "^0.3.4",
"@jridgewell/trace-mapping": "^0.3.7",
"@types/node": "*",
"chalk": "^4.0.0",
"collect-v8-coverage": "^1.0.0",
Expand All @@ -34,7 +34,7 @@
"slash": "^3.0.0",
"string-length": "^4.0.1",
"terminal-link": "^2.0.0",
"v8-to-istanbul": "^8.1.0"
"v8-to-istanbul": "^9.0.0"
},
"devDependencies": {
"@jest/test-utils": "^28.0.0-alpha.9",
Expand Down
5 changes: 1 addition & 4 deletions packages/jest-reporters/src/CoverageReporter.ts
Expand Up @@ -452,8 +452,7 @@ export default class CoverageReporter extends BaseReporter {
originalSource: fileTransform.originalCode,
source: fileTransform.code,
sourceMap: {
// remove `as any` after https://github.com/istanbuljs/v8-to-istanbul/pull/186 is released
sourcemap: {file: res.url, ...sourcemapContent} as any,
sourcemap: {file: res.url, ...sourcemapContent},
},
}
: {source: fs.readFileSync(res.url, 'utf8')},
Expand All @@ -465,8 +464,6 @@ export default class CoverageReporter extends BaseReporter {

const istanbulData = converter.toIstanbul();

converter.destroy();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


return istanbulData;
}),
);
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-source-map/package.json
Expand Up @@ -17,7 +17,7 @@
"./package.json": "./package.json"
},
"dependencies": {
"@jridgewell/trace-mapping": "^0.3.4",
"@jridgewell/trace-mapping": "^0.3.7",
"callsites": "^3.0.0",
"graceful-fs": "^4.2.9"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-transform/package.json
Expand Up @@ -19,7 +19,7 @@
"dependencies": {
"@babel/core": "^7.11.6",
"@jest/types": "^28.0.0-alpha.9",
"@jridgewell/trace-mapping": "^0.3.4",
"@jridgewell/trace-mapping": "^0.3.7",
"babel-plugin-istanbul": "^6.1.1",
"chalk": "^4.0.0",
"convert-source-map": "^1.4.0",
Expand Down
26 changes: 13 additions & 13 deletions yarn.lock
Expand Up @@ -2758,7 +2758,7 @@ __metadata:
"@jest/test-utils": ^28.0.0-alpha.9
"@jest/transform": ^28.0.0-alpha.10
"@jest/types": ^28.0.0-alpha.9
"@jridgewell/trace-mapping": ^0.3.4
"@jridgewell/trace-mapping": ^0.3.7
"@types/exit": ^0.1.30
"@types/glob": ^7.1.1
"@types/graceful-fs": ^4.1.3
Expand Down Expand Up @@ -2787,7 +2787,7 @@ __metadata:
string-length: ^4.0.1
strip-ansi: ^6.0.0
terminal-link: ^2.0.0
v8-to-istanbul: ^8.1.0
v8-to-istanbul: ^9.0.0
peerDependencies:
node-notifier: ^8.0.1 || ^9.0.0 || ^10.0.0
peerDependenciesMeta:
Expand All @@ -2808,7 +2808,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@jest/source-map@workspace:packages/jest-source-map"
dependencies:
"@jridgewell/trace-mapping": ^0.3.4
"@jridgewell/trace-mapping": ^0.3.7
"@types/graceful-fs": ^4.1.3
callsites: ^3.0.0
graceful-fs: ^4.2.9
Expand Down Expand Up @@ -2872,7 +2872,7 @@ __metadata:
"@babel/core": ^7.11.6
"@jest/test-utils": ^28.0.0-alpha.9
"@jest/types": ^28.0.0-alpha.9
"@jridgewell/trace-mapping": ^0.3.4
"@jridgewell/trace-mapping": ^0.3.7
"@types/babel__core": ^7.1.14
"@types/convert-source-map": ^1.5.1
"@types/fast-json-stable-stringify": ^2.0.0
Expand Down Expand Up @@ -2950,13 +2950,13 @@ __metadata:
languageName: node
linkType: hard

"@jridgewell/trace-mapping@npm:^0.3.0, @jridgewell/trace-mapping@npm:^0.3.4":
version: 0.3.4
resolution: "@jridgewell/trace-mapping@npm:0.3.4"
"@jridgewell/trace-mapping@npm:^0.3.0, @jridgewell/trace-mapping@npm:^0.3.7":
version: 0.3.7
resolution: "@jridgewell/trace-mapping@npm:0.3.7"
dependencies:
"@jridgewell/resolve-uri": ^3.0.3
"@jridgewell/sourcemap-codec": ^1.4.10
checksum: ab8bce84bbbc8c34f3ba8325ed926f8f2d3098983c10442a80c55764c4eb6e47d5b92d8ff20a0dd868c3e76a3535651fd8a0138182c290dbfc8396195685c37b
checksum: c08f5344568e1396fc377c95054b126620380a87e8992d77526f73b9627e56930a1a76ee95d31266d388ed052f6f97c64911c2aa49283d37547f51c342dfc9b8
languageName: node
linkType: hard

Expand Down Expand Up @@ -22240,14 +22240,14 @@ __metadata:
languageName: node
linkType: hard

"v8-to-istanbul@npm:^8.1.0":
version: 8.1.1
resolution: "v8-to-istanbul@npm:8.1.1"
"v8-to-istanbul@npm:^9.0.0":
version: 9.0.0
resolution: "v8-to-istanbul@npm:9.0.0"
dependencies:
"@jridgewell/trace-mapping": ^0.3.7
"@types/istanbul-lib-coverage": ^2.0.1
convert-source-map: ^1.6.0
source-map: ^0.7.3
checksum: 54ce92bec2727879626f623d02c8d193f0c7e919941fa373ec135189a8382265117f5316ea317a1e12a5f9c13d84d8449052a731fe3306fa4beaafbfa4cab229
checksum: d8ed2c39ba657dfd851a3c7b3f2b87e5b96c9face806ecfe5b627abe53b0c86f264f51425c591e451405b739e3f8a6728da59670f081790990710e813d8d3440
languageName: node
linkType: hard

Expand Down