chore(test): migrate from jest to vitest - #141
Open
catomean wants to merge 2 commits into
Open
Conversation
All 198 test files pass, 3492 tests green, 8 intentionally skipped.
jest.* -> vi.* is mostly mechanical, but several differences are not:
- jest ran CJS with moduleNameMapper; require() inside a test body ignored
the @/ alias under vitest's ESM runtime. Converted to await import().
- jest.requireActual is synchronous; vitest only has the async
vi.importActual, so 8 factories became async.
- jest tolerated a vi.mock-style factory closing over an outer const; vitest
hoists vi.mock above the temporal dead zone. vi.hoisted() wraps every
declaration a factory (including another vi.hoisted block) reads.
- jest's module interop accepted a factory returning a bare function as the
default export; vitest requires an explicit { default: Fn }.
- jest let a mock factory return a subset of a module's real exports; vitest
validates the mock's shape against every import site and refuses to run
the file if something used elsewhere is missing. Spread the real module via
vi.importActual and override only the property the test controls.
- jest.setTimeout(n) has no vi.setTimeout; the vitest equivalent is
vi.setConfig({ testTimeout: n }).
Config: two vitest projects (server/node, components/jsdom) replacing jest's
own projects array; transformIgnorePatterns is gone rather than translated,
since vitest loads ESM natively and that workaround existed only for jest's
CJS transform.
NOTE: PR #139 (generation lift) bumps jest to v30 on a separate branch. That
and this PR are mutually exclusive — keep jest v30, or remove jest for vitest.
Whoever reviews first should close the other.
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.
198/198 test files were green when this branch was cut. Merging master afterward pulled in commit #138 ("track whether the AI chain is actually up"), which adds
src/lib/ai/health.tscallingcreateHealthTrackerfromai-kit— an export that does not exist in the installedai-kit@0.4.0.health.tscalls it at module load time, so every file that transitively imports it (health.test.tsdirectly,provider.test.tsviaprovider.ts) now crashes on import: 2 files / 11 tests.This is unrelated to the jest→vitest migration and would fail under any runner that actually imports the module chain — it's not something this PR introduced or can fix (ai-kit is a shared package). Current state: 197/199 files, 3487/3495 non-skipped tests green, all 11 failures traced to this one missing export. See the top commit for the framework-migration details.
Also: #139 (generation lift) bumps jest to v30 on a separate branch. That and this PR are mutually exclusive — keep jest v30, or remove jest for vitest.