Skip to content

Replace Jest and Babel with Vitest and convert the tests to TypeScript - #509

Merged
jtklein merged 37 commits into
AntonelliLab:masterfrom
jtklein-agents:spec/295-replace-jest-and-babel-with-vitest-and-convert-the-tests-to-typescript
Nov 22, 2026
Merged

jtklein merged 37 commits into
AntonelliLab:masterfrom
jtklein-agents:spec/295-replace-jest-and-babel-with-vitest-and-convert-the-tests-to-typescript

Conversation

@jtklein-agents

Copy link
Copy Markdown
Contributor

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.

 package.json
-  jest, babel-jest, 5 direct @babel/* entries, the @babel resolutions pin
+  vitest, jsdom
   "test" / "react-test": jest --watchAll=false  →  vitest run   # name kept; CI unchanged
-jest.config.js
-jest/                      # babelTransform, fileMock, setup, bridge stubs
+vitest.config.mjs          # jsdom, globals off, ordered setup, 3 aliases; excluded from the packaged app
 src/
+├── test/                  # setup, mobxActionWarning, electron, sentry, storeBridge (.ts) + installBridge
 └── **/*.test.{js,jsx}  →  *.test.{ts,tsx}   # import { expect, test, vi } from 'vitest'; no @ts-nocheck
 yarn.lock                  # 133 Jest/Babel-only packages gone
  • Module reloading: jest.isolateModules(() => require(...)) → vi.resetModules(); await import(...).
  • Bridge stubs are typed against RendererBridge, so a test can no longer stub a bridge method that does not exist.
  • vitest.config.mjs includes only .ts/.tsx tests, so a leftover .test.js would not run silently.
  • @babel/* still in yarn.lock comes from eslint-config-react-app, @vitejs/plugin-react, electron-vite, @emotion/* and @mui/*, not from package.json.
  • Spec and child tickets: Bump nokogiri from 1.13.8 to 1.13.9 in /docs #295–Error #307 in the fork's tracker.

Evidence

  • Before (Jest, master at 2044cbc): Test Suites: 66 passed / Tests: 471 passed
    After (Vitest 5.1.1, branch tip bf1b927, fresh yarn install --frozen-lockfile): Test Files 67 passed (67) / Tests 474 passed (474). The extra file is src/test/installBridge.test.ts (3 tests).
  • yarn lint and yarn typecheck:baseline exit 0.
  • No @ts-nocheck in any test or support file; no jest / babel-jest / @babel/* in package.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 install after pulling. The first yarn react-test right 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

jtklein-agents and others added 30 commits November 22, 2026 17:37
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>
jtklein-agents and others added 7 commits November 22, 2026 20:39
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants