Skip to content

Stryker's vitest runner drops vitest.mutate.config.ts's testNamePattern, so the clock-face test it means to skip still runs #1940

Todo

Description

@V3RON

vitest.mutate.config.ts:13 sets testNamePattern to leave out ui/src/model/events.test.ts:148 ("is its time of day on the browser's clock face"), because that test sets process.env.TZ, which a worker thread ignores.

@stryker-mutator/vitest-runner 10.1.1 overwrites that pattern on every project in each run without test ids, the dry run included (node_modules/@stryker-mutator/vitest-runner/dist/src/vitest-test-runner.js:216-219):

this.ctx.projects.forEach((project) => {
    project.config.testNamePattern = undefined;
});

So the dry run runs the clock-face test anyway. In the thread pool it fails:

$ pnpm exec vitest run --config vitest.mutate.config.ts --pool threads ui/src/model/events.test.ts -t "clock face"
× is its time of day on the browser's clock face
AssertionError: expected '13:30:00' to be '17:00:00'

I read this from the runner's code and did not run Stryker (agents may not). If it holds, a pnpm mutate run whose test files include ui/src/model/events.test.ts (a mutant in ui/src/model/events.ts or something it imports) fails its first run. Possible fixes: exclude the test some other way (for example a skipIf on worker threads), or make it not depend on process.env.TZ.

Found while triaging #1938.

Written by an agent.

Activity

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

    @V3RON
    ContributorAuthor

    I could not reproduce this with the installed Vitest (5.1.0, ^5.0.5 in package.json). The dry run keeps the config's pattern, so the clock-face test is skipped and does not fail.

    Why the runner's line does nothing here: Vitest 5.1.0 copies a config's testNamePattern into vitest.configOverride at start (node_modules/vitest/dist/chunks/cli-api.COfZo8lK.js:12984). Each project's serialized config is then merged under that override (node_modules/vitest/dist/chunks/index.Di8au7q4.js:6762-6766). The runner's project.config.testNamePattern = undefined (vitest-test-runner.js:216-219) writes to the project's config, which sits under the override, so the pattern survives.

    What I tried: a unit test that creates Vitest in-process the way the runner's init() does (createVitest("test", { config: "vitest.mutate.config.ts", pool: "threads", maxWorkers: 1, watch: false })). It set every project's testNamePattern to undefined, as the runner's dry run does, and ran ui/src/model/events.test.ts:

    12 pass, "is its time of day on the browser's clock face" skipped, 0 fail
    project.config.testNamePattern after the write: undefined
    

    The command in the report fails for a different reason: -t "clock face" is a CLI pattern and replaces the config's pattern, so the test runs in a thread and fails. A Stryker dry run passes no -t.

    What would let me reproduce it: the output of a real pnpm mutate run (the maintainer's, or the harden-tests routine's) whose first run fails on "is its time of day on the browser's clock face", with the Vitest and @stryker-mutator/vitest-runner versions it used. Or a Vitest version this repo supports that does not keep the pattern in configOverride.

    A related problem I did find, filed as #1953: the same override also beats the runner's per-mutant filter (vitest-test-runner.js:212-215). Each mutant runs every test in its files, not just the ones that cover it.

    Written by an agent.

  4. removed
    bug:new
    on Nov 29, 2026
  5. removed their assignment
    on Nov 29, 2026
  6. added
    bug:needs-info
    on Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug:needs-info

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions