Skip to content

vitest.mutate.config.ts takes the console's DOM tests and runs them with no DOM, so all 21 fail #1938

Done

Description

@V3RON

vitest.mutate.config.ts:8 includes ui/**/*.test.{ts,tsx}, and its exclude list (line 10) leaves out only *.timing.test.ts. That pulls in every ui/**/*.dom.test.tsx. The unit project in vitest.config.ts leaves those files out, and the ui-dom project gives them environment: "happy-dom" and ui/src/test/setup.ts. The mutation config gives them neither.

On main at 6552987c6, pnpm exec vitest run --config vitest.mutate.config.ts fails 198 tests across all 21 DOM files, the same in the thread and the fork pool:

ReferenceError: window is not defined          (179 tests)
ReferenceError: HTMLElement is not defined     (19 tests)

A mutation run whose test files include a DOM file (a mutated ui/src/ file that a page test imports) fails its first run. Fix options: exclude ui/**/*.dom.test.tsx in the mutation config, or give it the ui-dom project.

Found while triaging #1937.

Written by an agent.

Activity

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

    @V3RON
    ContributorAuthor

    Reproduction

    Confirmed: all 21 DOM files, 198 tests, fail under the mutation config. src/test-lanes.repo.test.ts, "the mutation config (vitest.mutate.config.ts) › runs the console's DOM test files with the DOM the ui-dom project gives them, in Stryker's thread pool, and they pass", on bug/1938-repro. It runs two files: one fails inside a test, one fails while it loads.

    pnpm exec vitest run --project unit src/test-lanes.repo.test.ts -t "mutation config"
    
    -     "errors": [],
    +     "errors": ["ReferenceError: window is not defined"],
          "file": "ui/src/app/inbox-count.dom.test.tsx",
    -     "status": "passed",
    +     "status": "failed",
    -     "errors": [],
    +     "errors": ["HTMLElement is not defined"],
          "file": "ui/src/screens/fleet/worker-page.dom.test.tsx",
    

    The test pins one of the issue's two options: the DOM tests run, with their DOM. Excluding them fails it.

    Root cause

    Defect. vitest.mutate.config.ts:8 copies the unit project's include list from before #1454 (caa5b4e). That change moved ui/**/*.dom.test.tsx into a new ui-dom project with happy-dom and ui/src/test/setup.ts, and added them to unit's exclude list. The mutation config was not updated, so its single Node project still takes the DOM files and runs them without window. The symptom shows in Stryker's first run. The cause is the config drifting from vitest.config.ts:21-28,39-53.

    Simplest fix

    Split vitest.mutate.config.ts into two extends: true projects. unit: today's include list, with ui/**/*.dom.test.tsx added to exclude. ui-dom: the same environment, environmentOptions, setupFiles and css as vitest.config.ts.

    repro: 12 passed (test-lanes.repo.test.ts)
    all 21 DOM files, mutation config, --pool threads: 220 passed
    src/mutate.test.ts: 16 passed
    vitest list: the same 750 files before and after
    

    Alternatives rejected

    • Exclude the DOM tests (the issue's first option): mutants that only page tests kill would show as alive. That breaks delivery rule 18, which counts "the existing tests".
    • Import vitest.config.ts's projects: unit would also bring in packages/* and its setup file, which widens the change.

    Risk

    • The ui-dom block copies vitest.config.ts, so the two can drift apart again.
    • Mutation runs on ui/src/ take page tests: slower near and wide passes.
    • Not run under Stryker. Agents may not run it, so the first harden-tests run is the real check.

    Fast track

    • Defect: yes
    • Fix tried: yes
    • Nothing public added or broken: yes
    • No ADR or rule changed: yes
    • One fix: no — excluding the DOM tests changes which mutants a run reports alive

    Side findings

    Written by an agent.

  4. removed their assignment
    on Nov 28, 2026
  5. V3RON commented on Nov 30, 2026

    @V3RON
    ContributorAuthor

    Maintainer decision on the triage report (2026-11-30):

    Approved as proposed: the mutation config runs the console's DOM tests with their DOM.

    Deliver it after #1937 merges. #1937 moves Stryker's pool from threads to forks, so the reproduction's "in Stryker's thread pool" must follow that change.

    Written by an agent.

  6. added
    bug:ready
    and removed
    bug:new
    on Nov 30, 2026
  7. self-assigned this
    on Nov 30, 2026
  8. V3RON commented on Nov 30, 2026

    @V3RON
    ContributorAuthor

    Delivery run

    Merged: #1961 (#1938)

    Written by an agent.

  9. added a commit that references this issue on Nov 30, 2026
    ae2fd8a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug:ready

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions