Migrate test runner from Jest to vitest
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 197
- Forks
- 51
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 94
Description
Why
The wizard's source is already ESM ("type": "module" in package.json), but the test runner is still Jest. Jest's ESM support is opt-in and finicky, which is creating real friction now that the wizard depends on ESM-native packages.
Concrete pain point
The __mocks__/@posthog/warlock.ts file exists solely because Jest can't cleanly load the real @posthog/warlock package — it's ESM-only and loads a YARA-X WASM binary at runtime. The mock substitutes hand-written jest.fn() stand-ins for the real engine just so tests can import without crashing.
Sibling-repo precedent
Both PostHog projects in the same neighborhood already use vitest:
- warlock:
"test": "vitest run" - context-mill:
"test": "vitest run scripts/plugins/tests scripts/lib/tests"
A migration would unify test tooling across the three repos.
What's in scope
- Swap
jestforvitestindevDependenciesandpackage.jsonconfig - Convert
jest.fn()/jest.mock()calls tovi.fn()/vi.mock()(mostly mechanical) - Re-evaluate the warlock mock — vitest's native ESM may eliminate most of it. (WASM-in-test is its own conversation; partial mock may still be needed.)
- Make sure the smoke-test step in the postbuild flow still runs
What's out of scope
- Browser-environment changes
- Test rewrites beyond the framework swap
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with package.json to review the current Jest dependency, configuration, and test and postbuild scripts. Inspect mocks/@posthog/warlock.ts and the existing Jest calls, then run the test command and postbuild smoke-test step. Done means the Vitest suite passes, the smoke test still runs, and the warlock mock is reduced only where the migration permits.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- build-system, testing
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100