Skip to content

Migrate test framework from Jest to Vitest#47

Closed
Pearce-Ropion wants to merge 11 commits intomainfrom
claude/migrate-jest-to-vitest-MkXUq
Closed

Migrate test framework from Jest to Vitest#47
Pearce-Ropion wants to merge 11 commits intomainfrom
claude/migrate-jest-to-vitest-MkXUq

Conversation

@Pearce-Ropion
Copy link
Copy Markdown
Collaborator

Summary

This PR migrates the project's test framework from Jest to Vitest, modernizing the testing setup while maintaining the same test patterns and coverage.

Key Changes

  • Test runner migration: Updated npm scripts to use vitest run and vitest instead of Jest commands
  • Configuration: Replaced jest.config.ts with vitest.config.ts using Vitest's defineConfig API
  • Test API updates: Changed test mocks from jest.fn() and jest.resetAllMocks() to vi.fn() and vi.resetAllMocks() in test files
  • Dependencies: Removed Jest-related packages (jest, @jest/types, @types/jest, ts-jest, jest-environment-jsdom, jest-watch-typeahead) and added vitest and jsdom
  • TypeScript configuration: Added vitest/globals to the types array and updated include paths to reference the new Vitest config file

Implementation Details

  • Test file discovery pattern remains the same: src/**/*.test.{js,jsx,ts,tsx}
  • Test environment is configured as jsdom for DOM testing
  • Global test APIs are enabled via the globals: true option in Vitest config, allowing test functions to be used without explicit imports

https://claude.ai/code/session_017ZviPYnLaycC73S9VqYhgf

claude and others added 7 commits May 7, 2026 18:07
Replaces jest, ts-jest, jest-environment-jsdom, and related types with
vitest + jsdom. Test config moves from jest.config.ts to vitest.config.ts
(jsdom environment, globals enabled, same src/**/*.test.{js,jsx,ts,tsx}
glob). The lone test file swaps `jest.fn()`/`jest.resetAllMocks()` for
the equivalent `vi.*` APIs, and tsconfig now references vitest/globals
types.

https://claude.ai/code/session_017ZviPYnLaycC73S9VqYhgf
Drop `globals: true` from vitest.config.ts and remove the
`vitest/globals` types entry from tsconfig.json. Test files now
explicitly import `describe`, `it`, `expect`, `vi`, and the lifecycle
hooks from `vitest`.

https://claude.ai/code/session_017ZviPYnLaycC73S9VqYhgf
Swap the jsdom test environment for Vitest's browser mode running
Chromium via Playwright. Drops `jsdom`, bumps `vitest` to ^4.1.5,
and adds `@vitest/browser-playwright` and `playwright`. Also bumps
`@types/node` to ^24 to satisfy vitest 4's peer requirement
(matches the .nvmrc).

After install, run `npx playwright install chromium` once to fetch
the browser binary.

https://claude.ai/code/session_017ZviPYnLaycC73S9VqYhgf
Restore `globals: true` in vitest.config.ts and drop the explicit
`vitest` imports from test files. The `types` array in tsconfig.json
gets `vitest/globals`; it also needs `node` since specifying `types`
opts out of automatic @types inclusion.

https://claude.ai/code/session_017ZviPYnLaycC73S9VqYhgf
Comment thread src/client/initialize.ts
// send initialize event
void execPromise(
'wb:plugin:init',
require('../../package.json').version,
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This version thing is a feature we previously had for plugins that we removed (like 3 years ago) so removing this here shouldn't cause any issues.

It was causing issues with the test environment which is why it is being removed in this PR.

@Pearce-Ropion Pearce-Ropion requested review from a team, peternandersson and ryan-sigma May 7, 2026 21:20
@Pearce-Ropion Pearce-Ropion marked this pull request as ready for review May 7, 2026 21:20
Comment thread src/client/initialize.ts Outdated
const searchParams = new URLSearchParams(document.location.search);

for (const [key, value] of searchParams.entries()) {
if (value.startsWith('{')) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't assume that these search params will be objects

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.

3 participants