Sets up and repairs JavaScript / TypeScript unit tests - a suite that cannot resolve the project's path aliases (`@lib/...` declared in jsconfig or tsconfig), a regression that shipped because the tests asserted too little, or a module dependency that needs mocking, spying, or fake timers. Jest and Vitest as co-primary frameworks: install, config (`jest.config.js` / `vite.config.ts` test block), mocking (`jest.fn`/`jest.mock`/`jest.spyOn`, `vi.fn`/`vi.mock`/`vi.spyOn`, `__mocks__/`, fake timers), coverage (Istanbul/babel vs v8 providers, `coverageThreshold` gating), watch mode, and CI (`jest --ci`, `vitest run`, JUnit XML). Use when authoring, configuring, or repairing unit tests in a JS/TS project.
97
95%
Does it follow best practices?
Impact
98%
1.00xAverage score across 10 eval scenarios
Passed
No findings from the security scan
Companion reference for js-unit-tests. Consult when a legacy Jasmine
codebase (typically AngularJS-era, often paired with Karma for in-browser
runs) should move to Jest. Context: Karma has been in maintenance-only mode
since 2023, AngularJS reached end-of-life in January 2022, and new Angular
projects use Jest or Vitest - Karma + Jasmine setups are explicitly legacy.
Jest's API descends from Jasmine (describe, it, beforeEach,
expect(...).toBe(...), spies all originated there), so migration is mostly
mechanical.
The jest-codemods package handles ~80% of the syntax transformations:
npx jest-codemodsPoint it at the spec directory and review the diff - it rewrites Jasmine spy/matcher calls into their Jest equivalents.
spyOn().and.returnValue() with jest.spyOn().mockReturnValue().jasmine.createSpy() with jest.fn().jasmine.createSpyObj() with manual jest.fn() per method.expect().toBeNan() with expect(Number.isNaN(...)).toBe(true)
(matcher renamed).jest.config.js with an appropriate testMatch for the existing
spec layout (Jasmine's convention is spec/**/*[sS]pec.js).After migration, follow SKILL.md for Jest configuration, mocking, coverage, and CI.