Skip to content

Run the unchanged suite under Vitest on a throwaway branch and record what fails #287

Closed

Description

@jtklein-agents

Question

With the smallest config the research ticket supports, run the existing JavaScript tests under Vitest on a throwaway branch that is never merged. Which files pass unchanged, which fail, and what are the distinct failure causes? The answer is the failure list grouped by cause, with a pointer to the branch.

Activity

  1. added
    wayfinder:task
    on Nov 22, 2026
  2. jtklein-agents commented on Nov 22, 2026

    @jtklein-agents
    OwnerAuthor

    Context from jsdom for every test, or a Node environment for main-process and shell-config tests: run every file under jsdom with one setup list, no projects. Check two things specifically, because Vitest's jsdom keeps Node's setImmediate visible: (1) do the React-rendering tests (src/app/App.test.js, ErrorDialog, droppedFile, unhandledError) race jsdom teardown, as docs/agents/checks.md warns; (2) does src/main/updates.test.js still need its setImmediate polyfill.

  3. jtklein-agents commented on Nov 22, 2026

    @jtklein-agents
    OwnerAuthor

    Context from Where the test support files and the e2e helper tests live, and how they get typechecked: the 4 e2e/helpers tests stay beside their CommonJS helpers. Also record which form loads those helpers under Vitest: a plain import, or createRequire.

  4. jtklein-agents commented on Nov 22, 2026

    @jtklein-agents
    OwnerAuthor

    Resolution

    The spike is on the throwaway branch 287-vitest-spike (four commits, no PR, never merged). It installs vitest@5.1.1 and jsdom@29.1.1 with Yarn 1 and adds a 23-line vitest.config.js.

    Baseline: Jest runs 66 files and 471 tests, all passing.

    First run, tests unchanged (with globals: true and a one-line shim globalThis.jest = vi so the files load): 57 of 66 files pass. The 9 failing files have three causes.

    Cause Files Fix that worked on the branch
    JSX in a .js file: Vite does not parse it src/app/App.test.js, droppedFile.test.js, unhandledError.test.js, components/ErrorDialog.test.js Rename to .jsx (in the real change, .tsx). No content change.
    jest.isolateModules does not exist src/app/bootstrap.test.js, store/alignmentStore.test.js (1 test), store/host.test.js, store/provideStateReport.test.js vi.resetModules() then await import(). The tests and their loader helpers become async.
    jest.mock followed by require of a TypeScript module src/main/getActiveState.test.js vi.mock with the mock functions in vi.hoisted, then await import().

    After those fixes: 66 files and 471 tests pass, with the same test count per file as Jest. The diff outside yarn.lock is 13 files, +61 −41. Summed file time fell from about 41 s under Jest to about 14 s.

    Checks the other tickets asked for

    • React teardown race: not seen. The four React-rendering files passed five runs in a row with no unhandled error.
    • setImmediate polyfill in src/main/updates.test.js: not needed under Vitest's jsdom. The file passes with both lines deleted.
    • Loading the CommonJS e2e helpers: a plain import { parseNewick } from './newick' works, and so does the existing require. createRequire is not needed.

    Research risks that did not show

    • The electron alias not reaching electron-log and electron-store: updates.test.js passes.
    • mobxActionWarning as both setup file and import: its proof test passes.
    • jsdom 16 to 29: no test changed behaviour.
    • JSX runtime and define-semantics class fields: Vite reads them from tsconfig.json; @vitejs/plugin-react is not needed in the config.
    • clearMocks: the suite passes with clearMocks: false and with Vitest's default.
    • The two beforeEach( () => stubBridge() ) sites pass unchanged.

    New facts

    • vitest.config.js with ESM syntax prints a Vite warning on every run, because package.json has no "type": "module". Naming the file vitest.config.mjs removes the warning.
    • yarn add adds 43 packages to yarn.lock.

    Not covered: the spike kept the jest shim and ambient globals. It did not rename jest.* to vi.*, add the explicit vitest imports, convert anything to TypeScript, or remove Jest and Babel.

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

Metadata

Metadata

Labels

wayfinder:task

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions