Repository navigation
Replace Jest and Babel with Vitest and convert the tests to TypeScript - #509
Merged
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>
…itest-and-remove-jest-and-babel Run the tests under Vitest and remove Jest and Babel
Pure move of the five files in src/test; the Vitest config and the pack test point at the new names. Typing follows in the next commit. Refs #297 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Pure rename; Vitest's include now matches the new extension. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Pure move. Vitest's include gains ts and tsx so the renamed files still run. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Drops @ts-nocheck from the 12 tests. Partial stand-ins are cast where they are used; one mock takes a type argument because the test reads its calls. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The typecheck now includes the e2e helper tests, and the baseline script reads any file header, so a diagnostic in one of them fails the second pass. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
installBridge takes a Partial<RendererBridge>, merges it onto the one default bridge object the setup installed, and holds the only cast to the full type. It copies property descriptors, so a host getter is not read. stubBridge takes the same type and calls it. The default stubs now match the bridge types: cancelRun and cancelModelSelection resolve a promise, and checkOutput resolves the full result shape with an empty outputNameUnused, so the page still falls back to its placeholder name. The accessor keeps its setter for the tests that still assign a bridge directly. Vitest also picks up .test.ts and .test.tsx files. Refs #297 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ort-files-to-typescript-and-add-installbridge Convert the test support files to TypeScript and add installBridge
…ess-tests-to-typescript Convert the main-process tests to TypeScript (#298)
…with-vitest-and-convert-the-tests-to-typescript' into 299-convert-the-shell-config-and-e2e-helper-tests-to-typescript # Conflicts: # vitest.config.mjs
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Drops @ts-nocheck from the eight tests. Each bridge stub goes through installBridge instead of assigning window.rendererBridge. Partial store stand-ins are cast where they are used; one mock takes a type argument because the test reads its calls. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The scan skipped only .test.js files, so a page test renamed to .ts that imports fs or os would fail it. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The tests install their bridge through installBridge or stubBridge and use the shared track helper. The invariant-sites test sets '+I' where it set true: the option holds a string. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Each file installs its bridge methods with installBridge or stubBridge instead of assigning window.rendererBridge. Fixtures that carried the data type 'dna' as incidental parse output now carry 'nucleotide': the parser never sets 'dna'. The one loop that exercises the dead 'dna' case keeps it behind a ts-expect-error. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…fig-and-e2e-helper-tests-to-typescript Convert the shell-config and e2e helper tests to TypeScript
Drops @ts-nocheck from the four tests. Each installs its bridge with installBridge or stubBridge instead of assigning window.rendererBridge, so a stub the renderer bridge lacks fails the typecheck. runLifecycle and RunList use the shared stubBridge and track in place of their local copies. Partial stand-ins are cast where they are used. Test counts are unchanged: runLifecycle 17, RunList 20, startRun 3, cancelRun 2. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…s-outside-the-page-store-to-typescript Convert the page tests outside the page store to TypeScript (#300)
…e-partition-tests-to-typescript Convert the page store partition tests to TypeScript (#302)
…e-alignment-tests-to-typescript Convert the page store alignment tests to TypeScript (#301)
…with-vitest-and-convert-the-tests-to-typescript' into 304-convert-the-page-store-run-lifecycle-run-list-start-and-cancel-tests-to-typescript
…e-run-lifecycle-run-list-start-and-cancel-tests-to-typescript Convert the page store run lifecycle, run list, start and cancel tests to TypeScript
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…306) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…tion-tests-to-typescript Convert the page store substitution, tree, model and input-file option tests to TypeScript
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…l-tests Convert the page store citation, host, menu and small bridge-call tests to TypeScript
…typescript Convert the page store run computeds, options and input-action tests to TypeScript
Vitest now picks up only .ts and .tsx tests, and the Playwright config comment names Vitest instead of Jest. Closes #307. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-narrow-the-include-and-check-the-done-list Close the Vitest spec: narrow the include and check the done list
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.
Summary
The tests move from Jest + Babel to Vitest on the Vite the shell already uses, and every test and test support file becomes TypeScript. One feature branch, no app behaviour change.
jest.isolateModules(() => require(...))→vi.resetModules(); await import(...).RendererBridge, so a test can no longer stub a bridge method that does not exist.vitest.config.mjsincludes only.ts/.tsxtests, so a leftover.test.jswould not run silently.@babel/*still inyarn.lockcomes fromeslint-config-react-app,@vitejs/plugin-react,electron-vite,@emotion/*and@mui/*, not frompackage.json.Evidence
masterat2044cbc):Test Suites: 66 passed/Tests: 471 passedAfter (Vitest 5.1.1, branch tip
bf1b927, freshyarn install --frozen-lockfile):Test Files 67 passed (67)/Tests 474 passed (474). The extra file issrc/test/installBridge.test.ts(3 tests).yarn lintandyarn typecheck:baselineexit 0.@ts-nocheckin any test or support file; nojest/babel-jest/@babel/*inpackage.json.Merge Danger
Door: two-way
Revert the merge to get Jest back. Nothing ships to users: the packaged app excludes tests and
vitest.config.mjs.Blast Radius: tooling
Contributors need
yarn installafter pulling. The firstyarn react-testright after install failed once in 6 runs on my machine and passed on every rerun; I did not capture which test, so watch CI for a cold-start timeout.🤖 Generated with Claude Code