supercov 4.2.0 → 4.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docs/cli.md CHANGED
@@ -354,7 +354,17 @@ npx supercov diff <older-run> <newer-run>
354
354
 
355
355
  `diff` reports gains and losses. Use it after adding a test to prove that the
356
356
  expected behavior became covered without an unexplained regression elsewhere.
357
- Neither input run is changed.
357
+ Neither input run is changed. Under the totals it lists what was lost, marked
358
+ `-`, and then what was gained, marked `+`:
359
+
360
+ ```
361
+ gained: 1 lines, 1 branches, 0 MC/DC conditions
362
+ lost: 1 lines, 1 branches, 0 MC/DC conditions
363
+ - line src/fee.js:5
364
+ - branch src/fee.js:2 false
365
+ + line src/fee.js:3
366
+ + branch src/fee.js:2 true
367
+ ```
358
368
 
359
369
  Two runs of the same code can differ a little: what an end-to-end suite
360
370
  reaches depends on timing, on the order of tests, and on state outside the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "supercov",
3
- "version": "4.2.0",
3
+ "version": "4.2.1",
4
4
  "description": "Coverage, security and code quality for coding agents",
5
5
  "keywords": [
6
6
  "coverage",
@@ -119,14 +119,14 @@
119
119
  "test:windows-tls": "node scripts/windows-tls-test.mjs"
120
120
  },
121
121
  "optionalDependencies": {
122
- "@supercov/cli-darwin-arm64": "4.2.0",
123
- "@supercov/cli-darwin-x64": "4.2.0",
124
- "@supercov/cli-linux-arm64-gnu": "4.2.0",
125
- "@supercov/cli-linux-arm64-musl": "4.2.0",
126
- "@supercov/cli-linux-x64-gnu": "4.2.0",
127
- "@supercov/cli-linux-x64-musl": "4.2.0",
128
- "@supercov/cli-win32-arm64": "4.2.0",
129
- "@supercov/cli-win32-x64": "4.2.0"
122
+ "@supercov/cli-darwin-arm64": "4.2.1",
123
+ "@supercov/cli-darwin-x64": "4.2.1",
124
+ "@supercov/cli-linux-arm64-gnu": "4.2.1",
125
+ "@supercov/cli-linux-arm64-musl": "4.2.1",
126
+ "@supercov/cli-linux-x64-gnu": "4.2.1",
127
+ "@supercov/cli-linux-x64-musl": "4.2.1",
128
+ "@supercov/cli-win32-arm64": "4.2.1",
129
+ "@supercov/cli-win32-x64": "4.2.1"
130
130
  },
131
131
  "peerDependencies": {
132
132
  "@playwright/test": ">=1.55.0",
@@ -198,6 +198,7 @@ class CoveragePhaseController {
198
198
  cdpSessions = new Map();
199
199
  newDocumentScriptIds = new Map();
200
200
  pendingRegistrations = new Set();
201
+ pageRegistrations = new WeakMap();
201
202
  scriptUpdate = Promise.resolve();
202
203
  proxyCache = new WeakMap();
203
204
  runtimeSnapshots;
@@ -381,8 +382,27 @@ class CoveragePhaseController {
381
382
  }
382
383
  }
383
384
  }
384
- async registerPage(page) {
385
- if (this.pages.has(page) || this.disposed)
385
+ /**
386
+ * A page is registered once, and whoever asks while that is under way
387
+ * waits for it. Playwright announces a page to the context's listener
388
+ * before the fixture that hands it to the test has it, so the listener
389
+ * started the registration and the fixture, finding the page known,
390
+ * returned at once: the test's first `page.goto` began before the page had
391
+ * the session a phase is installed through. The document it loaded did not
392
+ * know its phase, and its hits were left to be placed by their time.
393
+ */
394
+ registerPage(page) {
395
+ if (this.disposed)
396
+ return Promise.resolve();
397
+ let registration = this.pageRegistrations.get(page);
398
+ if (!registration) {
399
+ registration = this.registerNewPage(page);
400
+ this.pageRegistrations.set(page, registration);
401
+ }
402
+ return registration;
403
+ }
404
+ async registerNewPage(page) {
405
+ if (this.pages.has(page))
386
406
  return;
387
407
  timingCount("registerPage");
388
408
  this.pages.add(page);
@@ -393,8 +413,15 @@ class CoveragePhaseController {
393
413
  adopted: !this.contexts.has(context) && tracked && !headersKnown,
394
414
  });
395
415
  const cdp = await page.context().newCDPSession(page).catch(() => undefined);
396
- if (cdp)
416
+ if (cdp) {
417
+ // Chromium runs a session's new-document scripts only once the
418
+ // session has enabled the Page domain. Without it the script that
419
+ // tells a document its phase was accepted and never ran: a page
420
+ // learned its phase only from the next action, after it had
421
+ // loaded, and everything it ran while loading was placed by time.
422
+ await cdp.send("Page.enable").catch(() => undefined);
397
423
  this.cdpSessions.set(page, cdp);
424
+ }
398
425
  const phaseId = this.requestPhaseId();
399
426
  if (phaseId)
400
427
  await this.activatePage(page, phaseId);