Skip to content

Commit 948539b

Browse files
committed
Workaround inaccurate Jest coverage reporting
This directly applies the following Pull Request: SimenB/collect-v8-coverage#235 It's not entirely clear why it's needed, but it seems reasonable and harmless enough, and there are no signs that Jest is really maintained anymore, so a longer-term fix does not appear to be forthcoming. Thus, this'll at least properly unblock Node upgrades and other annoying coverage surprises.
1 parent 9891e39 commit 948539b

File tree

3 files changed

+220
-2
lines changed

3 files changed

+220
-2
lines changed

package-lock.json

Lines changed: 194 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
"cron:report-lighthouse-results": "node dist/scripts/cronjobs/reportLighthouseResults.js",
4444
"db:migrate": "node -r dotenv-flow/config node_modules/knex/bin/cli.js migrate:latest --knexfile src/db/knexfile.js",
4545
"db:rollback": "node -r dotenv-flow/config node_modules/knex/bin/cli.js migrate:rollback --knexfile src/db/knexfile.js",
46-
"prepare": "husky",
4746
"storybook": "storybook dev -p 6006",
4847
"build-storybook": "npm run build-glean && npm run build-nimbus && storybook build",
4948
"create-location-data": "node src/scripts/build/uploadAutoCompleteLocations.js",
@@ -59,7 +58,9 @@
5958
"build-glean-backend-docs": "glean translate src/telemetry/backend-metrics.yaml --format markdown --output docs/telemetry/backend",
6059
"loadtest:hbibp-webhook": "echo 'Ensure k6 is installed; see:\n\thttps://grafana.com/docs/k6/latest/set-up/install-k6/\n' && k6 run src/scripts/loadtest/hibp.js",
6160
"validate-nimbus": "sh src/scripts/build/validate-nimbus-file.sh",
62-
"lighthouse": "lhci autorun"
61+
"lighthouse": "lhci autorun",
62+
"prepare": "husky",
63+
"postinstall": "patch-package"
6364
},
6465
"repository": {
6566
"type": "git",
@@ -162,6 +163,7 @@
162163
"jest-fail-on-console": "^3.3.1",
163164
"lint-staged": "^15.4.3",
164165
"mjml-browser": "^4.15.3",
166+
"patch-package": "^8.0.0",
165167
"prettier": "3.5.0",
166168
"sass": "^1.84.0",
167169
"storybook": "^8.4.6",
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
diff --git a/node_modules/collect-v8-coverage/index.js b/node_modules/collect-v8-coverage/index.js
2+
index 08b7853..db9ea66 100644
3+
--- a/node_modules/collect-v8-coverage/index.js
4+
+++ b/node_modules/collect-v8-coverage/index.js
5+
@@ -13,6 +13,8 @@ class CoverageInstrumenter {
6+
async startInstrumenting() {
7+
this.session.connect();
8+
9+
+ await this.postSession('Debugger.enable');
10+
+
11+
await this.postSession('Profiler.enable');
12+
13+
await this.postSession('Profiler.startPreciseCoverage', {
14+
@@ -30,6 +32,8 @@ class CoverageInstrumenter {
15+
16+
await this.postSession('Profiler.disable');
17+
18+
+ await this.postSession('Debugger.disable');
19+
+
20+
// When using networked filesystems on Windows, v8 sometimes returns URLs
21+
// of the form file:////<host>/path. These URLs are not well understood
22+
// by NodeJS (see https://github.com/nodejs/node/issues/48530).

0 commit comments

Comments
 (0)