Skip to content

vitest.mutate.config.ts's testNamePattern overrides Stryker's per-mutant test filter, so each mutant runs every test of its files #1953

Done

Description

@V3RON

vitest.mutate.config.ts:13 sets testNamePattern to leave out the clock-face test. Vitest 5.1.0 copies a config's testNamePattern into vitest.configOverride at start (node_modules/vitest/dist/chunks/cli-api.COfZo8lK.js:12984), and every project's serialized config is merged under that override (node_modules/vitest/dist/chunks/index.Di8au7q4.js:6762-6766).

On a mutant run, @stryker-mutator/vitest-runner 10.1.1 narrows the tests by writing project.config.testNamePattern = <regex of the covering test ids> (dist/src/vitest-test-runner.js:212-215). The override wins, so that regex is ignored: each mutant runs every test in the covering files except the clock-face one, not just the tests that cover it. Results stay right, but runs are slower.

What I saw: I created Vitest in-process the way the runner does (createVitest("test", { config: "vitest.mutate.config.ts", pool: "threads", maxWorkers: 1 })), set every project's testNamePattern to /is the workerId its payload names\s*$/, and ran ui/src/model/events.test.ts:

with vitest.mutate.config.ts:                12 run, 1 skipped (the clock-face test)
same config with the testNamePattern removed: 1 run (the named test), 12 skipped

So once the clock-face test stops depending on process.env.TZ (or is skipped in some other way), the config's testNamePattern can go and Stryker's filter will work again.

Found while triaging #1940.

Written by an agent.

Activity

  1. added
    bug:new
    on Nov 29, 2026
  2. self-assigned this
    on Nov 29, 2026
  3. V3RON commented on Nov 29, 2026

    @V3RON
    ContributorAuthor

    Reproduction

    Seen on: fakes (Vitest 5.1.0 created in-process the way @stryker-mutator/vitest-runner 10.1.1 does; Stryker itself not run)

    Confirmed as reported. src/mutate-config.test.ts, "runs only the two tests a mutant's filter names, and its dry run fails none of the file's tests", on bug/1953-repro. It reads stryker.config.mjs for the config file and pool (threads by default), writes a two-name filter on every project as the runner does, and runs ui/src/model/events.test.ts. The second half runs the dry run (filter undefined), so a fix that only drops the pattern fails too.

    $ pnpm exec vitest run --project unit src/mutate-config.test.ts
    AssertionError: expected [ …(12) ] to deeply equal [ …(2) ]
    

    All 12 non-clock-face tests ran instead of the two named ones.

    Root cause

    Defect. vitest.mutate.config.ts:13 sets testNamePattern. Vitest copies it into configOverride (vitest/dist/chunks/cli-api.COfZo8lK.js:12984), and that is merged over every project's config (index.Di8au7q4.js:6762-6766). So the runner's per-mutant project.config.testNamePattern = regex (vitest-test-runner.js:212-215) never takes effect. The pattern is there only because Stryker's default threads pool ignores the clock-face test's process.env.TZ.

    Simplest fix

    Delete the testNamePattern line and its comment from vitest.mutate.config.ts. In stryker.config.mjs, set vitest: { configFile: "vitest.mutate.config.ts", pool: "forks" } with a why comment: a forked process honours TZ, so the clock-face test passes there.

    $ pnpm exec vitest run --project unit src/mutate-config.test.ts src/mutate.test.ts src/test-lanes.repo.test.ts ui/src/model/events.test.ts
    Test Files  4 passed (4)
         Tests  41 passed (41)
    

    Dropping the pattern alone fails the dry-run half: expected [ 'failed' ] to deeply equal [].

    Alternatives rejected

    • it.skipIf(!isMainThread) on the clock-face test: the test lint refuses a skipIf that is not on process.platform or a SIMLOCK_ variable (testing rule 5).
    • Rewrite the clock-face test so it does not need TZ: a larger change to a console test, for the same result.

    Risk

    Fast track

    • Defect: yes
    • Fix tried: yes
    • Nothing public added or broken: yes
    • No ADR or rule changed: yes
    • One fix: yes

    Written by an agent.

  4. removed their assignment
    on Nov 29, 2026
  5. added
    bug:ready
    fast-track
    and removed
    bug:new
    on Nov 29, 2026
  6. self-assigned this
    on Nov 29, 2026
  7. V3RON commented on Nov 29, 2026

    @V3RON
    ContributorAuthor

    Delivery run

    Merged: #1954 (#1953)
    Parked: none
    Waiting: none
    Decided: none

    Written by an agent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug:readyfast-track

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions