Repository navigation
Description
Written from the map #285. Each decision below links to the ticket that settled it.
Problem Statement
The shell builds the app with Vite, but the tests run on a second toolchain: Jest, with a Babel transform that exists only for Jest. A developer keeps two transforms in step, carries a resolutions pin and a set of @babel/* packages that nothing else uses, and waits about 41 seconds of summed file time for 66 test files. The tests are also the last JavaScript the typecheck does not hold to the standard of the rest of src: they are .js, most carry @ts-nocheck, and 38 of them assign an untyped object to the renderer bridge, so a test can stub a bridge method that no longer exists and still pass.
Solution
The tests run under Vitest, on the Vite the shell already uses. Jest, babel-jest, every direct @babel/* entry and the Babel transform are gone. Every test file and test support file is TypeScript, held to the same bar as other TypeScript under src. yarn react-test and CI run Vitest, and the same 471 tests pass.
User Stories
- As a developer, I want the tests to run on the same Vite toolchain as the shell, so that I keep one transform instead of two.
- As a developer, I want
yarn react-testto keep its name and run Vitest, so that my habits and CI do not change. - As a developer, I want the same 471 tests in the same 66 files to pass after the swap, so that I know the swap lost no coverage.
- As a developer, I want the suite to finish faster, so that I run it more often.
- As a developer, I want no
jest,babel-jestor direct@babel/*entry inpackage.json, so that I have fewer dependencies to update. - As a developer, I want the Babel
resolutionspin removed, so that no stale pin shapes the lockfile. - As a developer, I want the removed packages gone from
yarn.lockas well, so that the lockfile matches the manifest. - As a developer, I want only
vitestandjsdomadded, so that the swap brings in no package nobody decided on. - As a developer, I want one Vitest config with one environment and one setup list, so that every test runs the same way.
- As a developer, I want the test run to print no config warning, so that real warnings stand out.
- As a developer, I want every test to import
test,expectandvifromvitest, so that I can see where each name comes from. - As a developer, I want Vitest globals off, so that
viandexpectare not in scope in production source. - As a developer, I want a stray
jest.or an unimportedexpectto fail the typecheck, so that CI catches a half-migrated test. - As a developer, I want the test support files in one directory under
src, so that the typecheck covers them like other source. - As a developer, I want no
jest/directory left, so that nothing suggests Jest is still in use. - As a developer, I want the default renderer bridge still installed before the page store loads, so that store tests keep importing
Runat the top of the file. - As a developer, I want the MobX action-warning check still applied to every test, so that an action outside a MobX action still fails a test.
- As a developer, I want the tests that reload a module to keep proving the same import-time behaviour, so that the swap does not weaken them.
- As a developer, I want the test that mocks a module to keep mocking it under Vitest, so that it still tests the unit alone.
- As a developer, I want the tests that render JSX to load under Vite, so that the page paint test still runs.
- As a developer, I want
yarn react-testto still fail on an empty page paint, so that the guard stays. - As a developer, I want the
setImmediatepolyfill removed from the one test that had it, so that no dead workaround stays. - As a developer, I want
yarn lintto pass with the Jest lint preset removed, so that lint does not depend on Jest. - As a developer, I want the disable comments for the removed lint rules deleted, so that lint does not report unknown rules.
- As a developer, I want every test file to be
.tsor.tsx, so that the editor andtsccheck my tests. - As a developer, I want converted tests to have zero diagnostics under
--noImplicitAny, so that tests meet the bar of other TypeScript undersrc. - As a developer, I want nothing added to the typecheck baseline, so that the conversion adds no debt.
- As a developer, I want no
@ts-nocheckor@ts-ignorein a test, so that no test is silently unchecked. - As a developer, I want
@ts-expect-errorallowed only with a one-line reason where a test passes a wrong type on purpose, so that runtime guards stay testable. - As a developer, I want one helper that installs a test bridge from a
Partial<RendererBridge>, so thattscchecks each bridge method a test supplies. - As a developer, I want a test that stubs a bridge method the renderer bridge no longer has to fail the typecheck, so that tests follow the bridge type.
- As a developer, I want
stubBridgeto go through that same helper, so that one place writes to the bridge. - As a developer, I want mocks written as plain
vi.fn(), with a type argument only wheretscasks for it, so that tests stay short. - As a developer, I want a partial store stand-in cast where it is used, so that there are no shared fixture builders to learn.
- As a developer, I want the e2e helper tests to stay beside their helpers and be typechecked, so that they meet the same bar without moving.
- As a developer, I want the Playwright specs left alone, so that this change touches one runner.
- As a reviewer, I want the runner swap in one pull request with no test converted to TypeScript, so that I review the runner change alone.
- As a reviewer, I want each conversion ticket to hold at most about 1,200 lines of test code, so that I can review it in one sitting.
- As a reviewer, I want each conversion to be a pure rename commit and then a typing commit, with the tests passing after each, so that the typing diff is readable.
- As a reviewer, I want the same test count per file before and after each ticket, so that I can see no test was dropped.
- As an agent picking up a ticket, I want the swap to block every conversion ticket, so that I never write types against Jest.
- As an agent picking up a ticket, I want the support-files ticket to block the page and store conversions, so that the bridge helper exists before I need it.
- As an agent picking up a ticket, I want the main-process and shell-config conversions to depend only on the swap, so that they run in parallel with the support-files ticket.
- As an agent picking up a ticket, I want the store conversions to touch separate files, so that they run in parallel without conflicts.
- As an agent picking up a ticket, I want the local agent docs to describe Vitest once the swap merges, so that I do not follow Jest instructions.
- As the driving dev, I want the swap ticket to carry the agent-doc edits as a checklist, so that I can apply them in the main checkout, where those files are kept out of git.
- As the driving dev, I want a closing ticket that checks the done list, so that the spec ends with Jest and Babel provably gone.
- As a maintainer, I want there never to be two test runners at once, so that CI and the config never split the files between them.
Implementation Decisions
- Add
vitest@^5.1.1andjsdom@^29.1.1as dev dependencies. jsdom 30 and later need a newer Node 22 than the repo pins. Any other new package needs its own decision.@vitejs/plugin-reactis not needed in the test config: Vite reads the JSX runtime and class-field semantics from the TypeScript config. - The config is a root
vitest.config.mjs(#292). Vitest cannot read the electron-vite config. The.mjsname avoids a Vite warning on every run. - One config for every test (#289): jsdom environment, one ordered setup list (bridge setup, then the MobX action-warning check), no projects and no per-file environment comments.
globalsis off.includecovers the tests undersrcand the e2e helper tests. - The config carries the aliases Jest's module-name map carried (
electron, the Sentry renderer entry) and the onefilenamifyalias from the renderer build. CSS needs no mapping. clearMocksis set tofalse, to match Jest. The suite passes either way; the explicit value keeps behaviour unchanged.
The swap: one ticket, one cutover (#292)
- All 66 test files move to Vitest while still JavaScript, and Jest and Babel are removed in the same ticket. There is no two-runner period.
jest.fn,jest.spyOnandjest.restoreAllMocksbecome thevi.*calls of the same name.- Every test and setup file imports the names it uses from
vitest(#288). Each file keepstestorit, whichever it uses today. - Five module-loading rewrites, as proven on the spike branch
287-vitest-spike: the four files that usejest.isolateModulesusevi.resetModules()andawait import(), and their tests and loader helpers becomeasync; the one file that usesjest.mockwithrequireuses a top-levelvi.mockwith its mock functions invi.hoisted, thenawait import(). - The four test files that hold JSX are renamed to
.jsxwith no content change. - The support files move from
jest/tosrc/test/, still JavaScript, with their import paths updated (#290). The Babel transform, the file mock and the Jest config are deleted. Nojest/directory remains. package.json: the test scripts run Vitest under the same script names;jest,babel-jest, every direct@babel/*entry and the Babelresolutionspin are removed, with theiryarn.lockstanzas.- The
react-app/jestlint preset is removed and nothing replaces it (#291). The fivetesting-librarydisable comments are deleted, because ESLint fails on a disable comment for a rule it does not know. - The
setImmediatepolyfill in the updates test is deleted. Vitest's jsdom keeps Node'ssetImmediate. - The swap ticket's body lists the edits to the local agent docs (the checks doc,
AGENTS.md,CODING_STANDARDS.md) as a checklist. Those files are kept out of git on the driving dev's clone, so no pull request carries them. The driving dev applies the checklist in the main checkout when the swap merges.
Typed tests (#293)
- One helper in
src/test/, namedinstallBridge, takesPartial<RendererBridge>, holds the only cast to the full type, and is the only code that writes towindow.rendererBridge.stubBridgetakes the same type and calls it. No test assigns towindow.rendererBridgedirectly. - The helper keeps the existing rule: a test's bridge is merged onto the one default bridge object the setup installed. It does not replace that object, and it does not spread or read
host. - Mocks are plain
vi.fn(). A type argument is added only where a test reads the mock's calls or results andtscasks for it. - A partial store stand-in is cast at the site. There are no shared fixture builders.
- No
@ts-nocheckand no@ts-ignore.@ts-expect-errorwith a one-line reason is allowed only where a test passes a wrong type on purpose to exercise a runtime guard. - These rules are added to
CODING_STANDARDS.mdthrough the swap ticket's doc checklist.
Conversion tickets (#294)
- Each conversion follows the existing leaf rule: a rename commit (
git mv, R100), then a typing commit, with the tests passing after each. Each ticket replaces the direct bridge assignments in its own files withinstallBridge. - Twelve tickets on the spec's feature branch. How the test files group into conversion tickets after the swap #294 lists the files of each store ticket.
| # | Ticket | Blocked by |
|---|---|---|
| 0 | The swap | none |
| 1 | Support files and installBridge |
0 |
| 2 | Main-process tests | 0 |
| 3 | Shell-config tests and e2e helper tests | 0 |
| 4 | Page tests outside the page store, with .jsx → .tsx |
1 |
| 5 | Page store: alignment | 1 |
| 6 | Page store: partition | 1 |
| 7 | Page store: run computeds, options and input actions | 1 |
| 8 | Page store: run lifecycle, run list, start and cancel | 1 |
| 9 | Page store: substitution, tree, model and input-file options | 1 |
| 10 | Page store: citation, host, menu and the small bridge-call tests | 1 |
| 11 | Closing ticket | 1 to 10 |
- Ticket 3 carries the typecheck wiring for the e2e helper tests: one include in the TypeScript config and a wider second pass in the typecheck-baseline script, so those four files meet the
--noImplicitAnybar. The four tests stay beside their CommonJS helpers and load them with a plainimport. - The closing ticket narrows the Vitest
includeto.tsand.tsx, fixes the comment in the Playwright config that says Jest owns*.test.js, and checks the done list below.
Done list
- Every file Jest runs today (62 under
src, 4 e2e helper tests) and the support files are TypeScript and run under Vitest, with the same tests passing. package.jsonhas nojest,babel-jestor direct@babel/*entry, including theresolutionspin, and the Babel transform is gone.- Converted tests have zero diagnostics under
--noImplicitAny, and nothing is added to the typecheck baseline. - CI's
yarn react-testruns Vitest.
Testing Decisions
- The seam is the existing one: the test suite, run by
yarn react-test, as CI runs it. This spec adds no seam and changes no production behaviour, so the suite is its own regression test. - A good check here compares outcomes, not internals: the same 66 files and 471 tests pass, with the same test count per file as under Jest on
master. Each ticket's pull request states the count before and after. - The one new module with logic is
installBridge. It gets a small test of its external behaviour: after the call, the page sees the supplied methods on the same default bridge object, and the defaults the setup stubs are still there. Prior art: the existing proof tests for the support files (thestubBridgetest and the MobX action-warning proof test). - Type behaviour is checked by
yarn typecheck:baseline, not by runtime tests: the second pass fails on any diagnostic in a.tsor.tsxfile, and an unimportedexpector a strayjest.is an undeclared name once Jest's types are gone. - Every ticket passes
yarn lint,yarn typecheck:baselineandyarn react-test, the three checks CI runs. - The swap ticket also proves the removed package names are absent from both
package.jsonandyarn.lock. - Prior art for the conversions: the earlier JS→TS leaves on the page and the main process, which used the same rename-then-type commits.
Out of Scope
- Replacing
eslint-config-react-appand the Babel it pulls in transitively. Vitest lint rules go with that effort. - Converting the Playwright specs, the Playwright configs and the non-test e2e helpers. They belong to a different runner.
- A Node environment for the tests that need no DOM.
- Adding, removing or rewriting tests beyond what the runner and the types require.
- Changes to production source. If a typed test exposes a wrong production type, that fix is its own ticket.
Further Notes
- The spike branch
287-vitest-spikeholds a working config and the nine file fixes. It is throwaway and is never merged; use it as a reference for the swap. It kept ambient globals and ajestshim, which the swap must not keep. - Known loss from removing the lint preset:
jest/valid-expect,jest/valid-expect-in-promise,jest/no-conditional-expectandjest/no-identical-title. TypeScript and Vitest's own failure on an unawaited async assertion cover part of that. - Line counts and file lists in How the test files group into conversion tickets after the swap #294 are from
masterat2044cbc. A ticket checks its file list against the tree before it starts. - The spike measured summed file time falling from about 41 s to about 14 s, and 43 packages added to
yarn.lockbefore the Jest and Babel removals.
Activity
jtklein-agents commentedon Nov 22, 2026
Merged upstream in AntonelliLab#509 (acd4e44). All child tickets #296–#307 are closed.