Skip to content

Restore 100% coverage under Vitest 4 (5.2.0) - #373

Merged
terehov merged 2 commits into
masterfrom
development
Sep 10, 2026
Merged

Restore 100% coverage under Vitest 4 (5.2.0)#373
terehov merged 2 commits into
masterfrom
development

Conversation

@terehov

@terehov terehov commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #370 before the 5.2.0 release. The Vitest 4 bump left coverage at 99.95 / 98.71 / 99.68 while CI stayed green: the new AST-based remapper counts the implicit else of every if, reports uncalled arrow functions, and binds v8 ignore hints to a single AST node (so next 3 counts stopped working), and neither Codecov nor vitest enforced a floor.

Coverage

  • Back to 100% on statements, branches, functions and lines: 34 new behavior tests (prototype-pollution guards in both spread orders, EPIPE on stdout, stale file-stream errors, malformed/hostile source maps, partial req/res shapes, unknown worker messages, multi-write flush, production-silenced diagnostics, ...), a handful of provably redundant guards simplified, and justified v8 ignore else hints only for defensive paths no caller can reach.
  • coverage.thresholds in vitest.config.ts now pins all four metrics at 100%, so npm run coverage (the Node 20 CI job) fails on the next drop.

Fixed (found while covering those paths, all in the 5.2.0 changelog)

  • A frozen or getter-based default LogObj made every log call throw Cannot assign to read only property.
  • A source map that is valid JSON but structurally wrong ("sections":[null], non-string mappings) threw a TypeError out of the log call.
  • Worker transport flush() rejected forever after a failed new Worker() although writes had already gone inline.
  • restoreConsole() left tslog's forwarder on a console method that did not exist before wrapConsole().

Verified locally: Node 24 (1675 tests, 100% coverage), Bun, Chromium browser suite, tsgo, biome, doc-sync.

Vitest 4's AST-based remapper counts the implicit else of every if,
reports uncalled arrow functions and binds v8 ignore hints to a single
node, which left 42 branches and 2 functions uncovered after the bump.
coverage.thresholds now pins all four metrics at 100% so CI fails on the
next drop instead of reporting it quietly.

Also fixes bugs surfaced while covering those paths:
- a frozen or getter-based default LogObj made every log call throw
- a structurally hostile source map threw a TypeError out of the log call
- worker transport flush() rejected forever after a failed spawn
- restoreConsole() left a forwarder on a console that lacked the method
@codecov

codecov Bot commented Sep 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (7b7085f) to head (3d91991).

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #373   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           53        53           
  Lines         4642      4628   -14     
  Branches      1425      1361   -64     
=========================================
- Hits          4642      4628   -14     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@terehov
terehov merged commit 4cc8dd2 into master Sep 10, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant