Repository navigation
Description
Parent
What to build
yarn react-test and CI run the same 471 tests in the same 66 files under Vitest, on the Vite the shell already uses. Jest, babel-jest, every direct @babel/* entry and the Babel transform are gone in the same pull request: there is never a period with two test runners. No test is converted to TypeScript here.
The spike branch 287-vitest-spike holds a working config and the file fixes. Use it as a reference only: it is never merged, and it kept ambient globals and a jest shim, which this ticket must not keep.
Decisions that shape the change:
- Dev dependencies added:
vitest@^5.1.1andjsdom@^29.1.1, and no other package.@vitejs/plugin-reactis not needed. - One root
vitest.config.mjs: jsdom environment, one ordered setup list (bridge setup, then the MobX action-warning check),globalsoff,clearMocks: false, no projects, no per-file environment comments.includecovers the tests undersrcand the e2e helper tests. Aliases:electron, the Sentry renderer entry, and the onefilenamifyalias from the renderer build. CSS needs no mapping. jest.fn,jest.spyOnandjest.restoreAllMocksbecome thevi.*calls of the same name. Every test and setup file imports the names it uses fromvitest, and keepstestorit, whichever it uses today.- The four files that use
jest.isolateModulesusevi.resetModules()andawait import(); their tests and loader helpers becomeasync. The one file that usesjest.mockwithrequireuses a top-levelvi.mockwith its mock functions invi.hoisted, thenawait import(). - The test files that hold JSX are renamed to
.jsxwith no content change. - The support files move from
jest/tosrc/test/, still JavaScript, with import paths updated.
Out of scope: converting any test to TypeScript, the installBridge helper, replacing eslint-config-react-app, the Playwright specs, changes to production source.
Acceptance criteria
-
yarn react-testandyarn testrun Vitest once (no watch) under their current script names, and CI'syarn react-teststep runs Vitest. - The same 66 files and 471 tests pass. The pull request states the test count per file under Jest on
masterand under Vitest, and they are equal. - The run prints no config warning.
-
package.jsonhas nojest, nobabel-jest, no direct@babel/*entry (package.json:88-92,105,115), and no Babelresolutionspin (package.json:219). Onlyvitestandjsdomare added. -
yarn.lockhas no stanza that only the removed entries required. A@babel/*or*jest*stanza thateslint-config-react-appstill requires stays. The pull request lists the removed names it proved absent from both files, and the names that remain with the package that requires each. Do not run a fresh install to check the lock. -
jest.config.js, the Babel transform and the CSS file mock are deleted, and nojest/directory remains. The!jest{,/**/*}packaging exclude (package.json:144) and thejest/setup.jsassertion in the pack test (src/pack.test.js:65) are removed or updated, and the support files still stay out of the packaged app. - The lint scripts (
package.json:54-55) no longer namejest.config.jsorjest/**, and lint coversvitest.config.mjs. - No test or support file contains
jest.; each imports what it uses fromvitest. Vitestglobalsis off. - The default renderer bridge is still installed before the page store loads: store tests still import
Runat the top of the file. - The MobX action-warning check still applies to every test, and its proof test still passes.
- The four module-reloading tests still prove the same import-time behaviour, and the module-mocking test still mocks its module.
-
yarn react-teststill fails on an empty page paint. - The
setImmediatepolyfill in the updates test is deleted (src/main/updates.test.js:4,7). - The
react-app/jestlint preset is removed (.eslintrc.cjs:3) and nothing replaces it. The fivetesting-librarydisable comments are deleted (src/app/components/ErrorDialog.test.js:13,43,src/app/droppedFile.test.js:42,src/app/unhandledError.test.js:21,src/app/App.test.js:10). -
yarn lint,yarn typecheck:baselineandyarn react-testpass, and nothing is added to the typecheck baseline. - The pull request states whether
instanceof Errorstill fails under Vitest's jsdom for an error Node'sfsthrows (theCODING_STANDARDS.mdrule "Catch message under Jest" depends on it).
Agent-doc edits (driving dev, main checkout, when this merges)
These files are kept out of git, so no pull request carries them. Line numbers are from master at 2044cbc.
-
AGENTS.md:5: "or Jest setup" → "or Vitest setup". -
docs/agents/issue-tracker.md:11: "Jest setup" → "Vitest setup". -
docs/agents/checks.md:7: "the ticket's Jest files" → "the ticket's Vitest files". -
docs/agents/checks.md:11: "Jest loads the page without the preload, sojest/setup.jsowns" → "Vitest loads the page without the preload, sosrc/test/setup.jsowns". "Jest uses jsdom." → "Vitest uses jsdom, and its jsdom keeps Node'ssetImmediate; no test polyfills it." Delete the three sentences from "Main-process production code keeps bare Node globals" to "races jsdom teardown." -
docs/agents/checks.md:13: "keeps a Jest literal" → "keeps a test literal". -
docs/agents/checks.md:19: "Jest does not transformelectron-vite, so they load" → "They load". -
docs/agents/renderer-bridge.md:17: "a Jest test of a pure function" → "a Vitest test of a pure function".:32: "runs on Jest" → "runs on Vitest". -
CODING_STANDARDS.md:33:jest/storeBridge.js→src/test/storeBridge.js. -
CODING_STANDARDS.md:43-45: rename "Catch message under Jest" to "Catch message under Vitest" and replace "Jest's jsdom" with "Vitest's jsdom", if the pull request reports the realm mismatch still holds; otherwise delete the section. -
CODING_STANDARDS.md:49: delete the two sentences about polyfillingsetImmediateand the shared Jest setup. -
CODING_STANDARDS.md: add a "Typed tests" section:- A test installs its bridge with
installBridgefromsrc/test/, which takesPartial<RendererBridge>. No test assigns towindow.rendererBridge.stubBridgegoes through the same helper. - Mocks are plain
vi.fn(). Add a type argument only where a test reads the mock's calls or results andtscasks for it. - A partial store stand-in is cast where it is used. No shared fixture builders.
- No
@ts-nocheckand no@ts-ignorein a test.@ts-expect-errorwith a one-line reason is allowed only where a test passes a wrong type on purpose to exercise a runtime guard. - Every test imports
testorit,expectandvifromvitest.
- A test installs its bridge with
Activity
Replace Jest and Babel with Vitest and convert the tests to TypeScript (