Repository navigation
Conversation
Nothing imports them. The helpers date from the old in-browser test page.
Replaces chai assert with expect, removes empty hooks and commented-out tests, merges duplicate hooks and describe blocks, gives duplicate test titles distinct names, trims trailing spaces in titles, and fixes titles that did not match what the test checks.
retrieveManifest starts a real manifest request. It reached the network and finished at a random time after the test, which made coverage differ between runs.
Rejects focused, skipped and commented-out tests, duplicate titles and hooks, tests without an assertion, done callbacks, and chai assert/should and chai-spies imports. Files that still use done callbacks or have tests without an assertion are listed in DONE_CALLBACK_FILES and NO_EXPECT_FILES; the area PRs of #5210 shrink these lists.
npm run test:coverage fails below the floor in vite.config.js (57.33% lines on Chromium). On pull requests, the coverage summary fails when less than 80% of the changed executable lines in src/ are covered (--min-changed=80).
test/unit/README.md describes structure, assertions, mocks, lint rules and the coverage rules agreed in #5210. Linked from AGENTS.md.
With --min-changed, a malformed coverage summary, a missing base ref or an invalid threshold let the check pass. The check now passes only once the coverage of the changed lines is known.
lcov.info lists a statement only on its first line. A change to a later line of a multiline statement, for example a condition on its own line, counted as a change without executable code and could not fail the check. The check now reads the statement spans from coverage-final.json and gives such a line the hit count of the innermost statement it belongs to. Blank lines, comments and lines with only closing brackets still do not count.
…summary --min-changed= read as 0, and --min-changed 80 (with a space) left the check off and read 80 as the coverage folder. Arguments are now parsed with node:util parseArgs: both forms work, and unknown options, extra arguments and missing or malformed thresholds exit with code 2.
When ci:verify failed, the coverage step was skipped and the summary failed a second time with "no coverage report found".
The two tests checked spy.notCalled before registering the spy and before calling setPlaybackQuality, so they could never fail.
…t test The title says the test covers on-receive and on-start mode, but nothing required the on-receive handler to run, and an assertion error inside it never reached done. The handler now records the event, and the on-start handler asserts it.
No behaviour change: the coverage summary produces the same output. changed-lines.mjs decides which changed lines are executable and how often they ran; it is tested against coverage objects from @vitest/istanbul-lib-instrument, the instrumenter @vitest/coverage-istanbul uses. coverage-summary.test.mjs covers the arguments and the cases in which --min-changed must fail. npm run test:scripts runs both with node --test and is part of ci:verify.
The hand-written comment scan read /* inside a string such as '*/*', a regular expression or a template literal as the start of a comment, and dropped the following lines until the next */. Uncovered changes on those lines passed the check. acorn tokenizes the file instead; a line has code when it holds a token other than closing brackets, ';' or ','.
istanbul does not instrument the expression of 'export default <expression>', such as export default FactoryMaker.getClassFactory(...). A change to only that line counted as a change without executable code and passed, even in a file no test loads. These lines now get the module load count: the highest count of the statements outside every function.
dsilhavy
force-pushed
the
feature/test-conventions
branch
from
November 29, 2026 07:12
7a4930f to
159bc99
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Second step of #5210. It writes down how unit tests are written from now on, enforces it with lint rules, and stops coverage from dropping.
Changes
test/unit/README.mddescribes the test conventions and coverage rules;AGENTS.mdlinks to it.@vitest/eslint-pluginrejects focused, skipped and commented-out tests, duplicate titles, tests without an assertion,donecallbacks and chaiassert. Files not converted yet are listed ineslint.config.mjs; the area PRs only shrink these lists.npm run test:coveragefails below a floor of 57.33% lines (Chromium). On pull requests, CI fails when less than 80% of the changed executable lines insrc/are covered.retrieveManifesttests use fake XHR instead of real network requests.Verification
npm run ci:verifypasses locally: 4488/4488 tests in Chromium and Firefox.npm run test:coveragepasses: 57.41% lines.src/lines, and fails below the threshold and without a coverage report.