Repository navigation
Run the tests under Vitest and remove Jest and Babel - #308
Merged
jtklein-agents merged 1 commit intoNov 22, 2026
Conversation
yarn react-test and yarn test now run `vitest run` on the Vite the shell already uses. Jest, babel-jest, every direct @babel/* entry, the Babel resolutions pin, jest.config.js, the Babel transform and the CSS file mock are gone. Only vitest and jsdom are added. - One root vitest.config.mjs: jsdom, globals off, ordered setup (bridge, then the MobX action-warning check), aliases for electron, the Sentry renderer entry and filenamify. - Support files move from jest/ to src/test/. - Every test and support file imports what it uses from vitest; jest.fn/spyOn/restoreAllMocks become the vi.* calls. - The four jest.isolateModules files use vi.resetModules() and await import(); getActiveState uses vi.hoisted with a top-level vi.mock. - The four tests that hold JSX are renamed to .jsx, and the page Node-import scan skips .test.jsx as it skips .test.js. - The setImmediate polyfill, the react-app/jest lint preset and the five testing-library disable comments are deleted. - vitest.config.mjs is excluded from the packaged app, with a pack-test assertion. Same 66 files and 471 tests pass, with equal per-file counts under Jest on master and under Vitest. Notes for the pull request: - Under Vitest's jsdom, `instanceof Error` is true for an error Node's fs throws, and Node's setImmediate is present. The realm mismatch behind "Catch message under Jest" no longer holds. - yarn lint exits 0 but now prints a babel-preset-react-app notice: without the removed resolutions pin, @babel/plugin-proposal-private-property-in-object resolves to the preset-env placeholder. - yarn.lock: jest, babel-jest, every @jest/* and jest-* stanza are gone (133 names removed in all). Remaining @babel/* stanzas are required by eslint-config-react-app, @vitejs/plugin-react, electron-vite, @emotion or @mui; eslint-plugin-jest stays for eslint-config-react-app. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
jtklein-agents
merged commit Nov 22, 2026
dca2548
into
spec/295-replace-jest-and-babel-with-vitest-and-convert-the-tests-to-typescript
9 checks passed
jtklein-agents
deleted the
296-run-the-tests-under-vitest-and-remove-jest-and-babel
branch
November 22, 2026 17:29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #296. Part of #295.
Summary
yarn react-test,yarn testand CI'syarn react-teststep now runvitest runon the Vite the shell already uses. Jest and Babel leave in the same change, so there is never a second test runner.Module reloading, in
bootstrap,host,provideStateReportandalignmentStoretests:getActiveState.test.jskeeps its mock: the mock functions sit invi.hoisted,vi.mockis top-level, and the module loads withawait import().Also deleted: the
setImmediatepolyfill insrc/main/updates.test.jsand the fivetesting-librarydisable comments.Beyond the ticket's list:
!vitest.config.mjsin the packaging excludes, with one assertion insrc/pack.test.js. The support files stay out through the existing!src{,/**/*}; the assertion now namessrc/test/setup.js.src/pageNodeImports.test.jsskips.test.jsxas it skips.test.js, so the four renamed tests are not read as page source.// @ts-nocheck — Jest globals…reason in each test is reworded to "the test is not typed yet". The old reason was no longer true.Evidence
masterat2044cbc):Test Suites: 66 passed, 66 total/Tests: 471 passed, 471 totalAfter (Vitest 5.1.1):
Test Files 66 passed (66)/Tests 471 passed (471)yarn lint,yarn typecheck:baselineandyarn react-testexit 0.scripts/typecheck-baseline.txtis unchanged.src/mobxActionWarning.test.js, 2 tests) passes, andsrc/app/App.test.jsxkeeps its empty-paint assertion unchanged. I did not mutate the page to watch that assertion fail.instanceof Errorunder Vitest's jsdom: it no longer fails. A probe test caught the error fromfs.readFileSync( '/nope/nope' )and gotcaught instanceof Error === true;typeof setImmediateis'function'. The realm mismatch behind theCODING_STANDARDS.mdrule "Catch message under Jest" does not hold under Vitest. Theno-restricted-syntaxrule in.eslintrc.cjsthat cites the same mismatch is untouched here.yarn.lockpackage.jsonandyarn.lock:jest,babel-jest, every@jest/*and everyjest-*name,babel-plugin-jest-hoist,babel-preset-jest,babel-plugin-istanbul. 133 names left the lock in all (list below).package.json, still inyarn.lockbecauseeslint-config-react-apprequires them:@babel/plugin-proposal-class-properties,@babel/plugin-proposal-private-property-in-object,@babel/plugin-transform-react-jsx,@babel/preset-env,@babel/preset-typescript.@babel/*stanzas: 107 reached only fromeslint-config-react-app;@babel/coreand its helpers also from@vitejs/plugin-reactandelectron-vite;@babel/parser,traverse,types,generator,template,code-framealso from@emotion/*;@babel/runtimealso from@emotion/*and@mui/*;@babel/plugin-transform-react-jsx-selfand-sourcefrom@vitejs/plugin-react.*jest*stanza iseslint-plugin-jest, required byeslint-config-react-app.yarn removeandyarn add, and checked by walking the lock's dependency graph from the direct dependencies. No fresh install.133 names removed from yarn.lock
@babel/plugin-bugfix-safari-rest-destructuring-rhs-array @babel/plugin-syntax-bigint @babel/plugin-transform-explicit-resource-management @babel/plugin-transform-regexp-modifiers @bcoe/v8-coverage @istanbuljs/load-nyc-config @istanbuljs/schema @jest/console @jest/core @jest/environment @jest/fake-timers @jest/globals @jest/reporters @jest/source-map @jest/test-result @jest/test-sequencer @jest/transform @jest/types @sinonjs/commons @sinonjs/fake-timers @types/graceful-fs @types/istanbul-lib-coverage @types/istanbul-lib-report @types/istanbul-reports @types/prettier @types/stack-utils @types/yargs @types/yargs-parser abab acorn-globals acorn-walk ansi-escapes anymatch babel-jest babel-plugin-istanbul babel-plugin-jest-hoist babel-preset-current-node-syntax babel-preset-jest browser-process-hrtime bser camelcase char-regex cjs-module-lexer co collect-v8-coverage cssom cssstyle dedent detect-newline diff-sequences domexception emittery escodegen esprima execa exit expect fb-watchman get-package-type html-escaper human-signals import-local is-generator-fn istanbul-lib-coverage istanbul-lib-instrument istanbul-lib-report istanbul-lib-source-maps istanbul-reports jest jest-changed-files jest-circus jest-cli jest-config jest-diff jest-docblock jest-each jest-environment-jsdom jest-environment-node jest-get-type jest-haste-map jest-jasmine2 jest-leak-detector jest-matcher-utils jest-message-util jest-mock jest-pnp-resolver jest-regex-util jest-resolve jest-resolve-dependencies jest-runner jest-runtime jest-serializer jest-snapshot jest-util jest-validate jest-watcher jest-worker kleur leven makeerror merge-stream node-int64 normalize-path npm-run-path nwsapi pirates pkg-dir pretty-format prompts querystringify regjsgen requires-port resolve-cwd resolve.exports sisteransi sprintf-js stack-utils string-length strip-final-newline supports-hyperlinks terminal-link test-exclude throat tmpl type-detect typedarray-to-buffer url-parse v8-to-istanbul w3c-hr-time walker whatwg-encoding write-file-atomic ws
Test count per file: 66 files, 471 tests, equal under both runners
master)e2e/helpers/modeltestOutcome.test.jse2e/helpers/newick.test.jse2e/helpers/raxmlHpcOutcome.test.jse2e/helpers/raxmlNgOutcome.test.jssrc/app/App.test.jsxsrc/app/bootstrap.test.jssrc/app/components/ErrorDialog.test.jsxsrc/app/droppedFile.test.jsxsrc/app/paths.test.jssrc/app/promisedComputed.test.jssrc/app/report.test.jssrc/app/store/AlignmentOptions.test.jssrc/app/store/InputFile.test.jssrc/app/store/Option.test.jssrc/app/store/OutGroup.test.jssrc/app/store/Part.test.jssrc/app/store/Partition.test.jssrc/app/store/Run.computeds.test.jssrc/app/store/RunList.test.jssrc/app/store/RunSimpleOptions.test.jssrc/app/store/alignmentStore.test.jssrc/app/store/astral.test.jssrc/app/store/cancelRun.test.jssrc/app/store/checkOutputName.test.jssrc/app/store/citationConfig.test.jssrc/app/store/finalAlignment.test.jssrc/app/store/host.test.jssrc/app/store/loadAlignment.test.jssrc/app/store/loadAstralTree.test.jssrc/app/store/loadPartitionFile.test.jssrc/app/store/loadTree.test.jssrc/app/store/menu.test.jssrc/app/store/modelSelection.test.jssrc/app/store/openPath.test.jssrc/app/store/pageStoreGaps.test.jssrc/app/store/parseAlignment.test.jssrc/app/store/provideStateReport.test.jssrc/app/store/readText.test.jssrc/app/store/runInputActions.test.jssrc/app/store/runLifecycle.test.jssrc/app/store/selectOutputDir.test.jssrc/app/store/showItemInFolder.test.jssrc/app/store/startRun.test.jssrc/app/store/substitutionOptions.test.jssrc/app/store/treeFileOptions.test.jssrc/app/store/version.test.jssrc/app/store/writeConcatenatedAlignment.test.jssrc/app/unhandledError.test.jsxsrc/main/cancelRun.test.jssrc/main/checkOutput.test.jssrc/main/debugInfo.test.jssrc/main/getActiveState.test.jssrc/main/pageWindowPreferences.test.jssrc/main/parseAlignment.test.jssrc/main/selectAlignment.test.jssrc/main/selectAstralFile.test.jssrc/main/selectOutputDir.test.jssrc/main/selectPartitionFile.test.jssrc/main/selectTree.test.jssrc/main/updates.test.jssrc/mobxActionWarning.test.jssrc/pack.test.jssrc/pageNodeImports.test.jssrc/preload.test.jssrc/sourceMaps.test.jssrc/typecheckBaseline.test.jsMerge Danger
Door: two-way
Reverting the commit restores Jest and the old lock. It merges into the spec's feature branch, not
master.Blast Radius: tooling
No production source changes. Two things to know:
yarn lintstill exits 0 but now prints ababel-preset-react-appnotice. Without the removedresolutionspin,@babel/plugin-proposal-private-property-in-objectresolves to thepreset-envplaceholder. Keeping the pin would silence it, against the ticket.jest/setup.jsare outside git; the ticket lists those edits for the main checkout after merge.🤖 Generated with Claude Code