/testing-frameworks:javascript-typescript-jestfrom testing-frameworks
Writes and reviews Jest tests for JavaScript and TypeScript projects, including mocks, async handling, snapshots, and React Testing Library patterns. Helps add tests, improve structure, mock APIs/databases, and test React components.
Ships in testing-frameworks. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Write focused JavaScript and TypeScript Jest tests by selecting file placement, isolation boundaries, matcher style, async handling, and React Testing Library queries, then return a runnable test plan or test implementation summary.
Use this for JavaScript/TypeScript test work where Jest is the runner.
| Concern | Rule | Example |
|---|---|---|
| File names | Name test files with .test.ts or .test.js suffix. Use .test.tsx or .test.jsx for JSX when the project uses those extensions. | calculator.test.ts, SearchBox.test.tsx |
| Location | Place tests next to the code they test or in a dedicated __tests__ directory; follow the repository's existing convention. | src/foo.test.ts or src/__tests__/foo.test.ts |
| Names | Use descriptive test names that explain expected behavior, not implementation mechanics. | it('returns an empty list when the API has no results', ...) |
| Grouping | Use nested describe blocks only when they add signal around a component, function, class, method, or state. | describe('UserService', () => { describe('createUser', () => { ... }) }) |
| Shape | Follow describe('Component/Function/Class', () => { it('should do something', () => {}) }) when no local style is stronger. | Keep setup near the assertions it supports. |
Prefer arrange-act-assert within each test. Keep one behavioral reason to fail per test; split tests when the assertion list starts describing multiple scenarios.
| Need | Jest primitive | Guidance |
|---|---|---|
| Replace a module for the whole file | jest.mock() | Mock external dependencies such as APIs, databases, queues, file systems, clocks, and network clients to isolate the unit under test. |
| Observe or override one exported function or object method | jest.spyOn() | Restore spies after the test, especially for globals such as Date, console, fetch, or Math.random. |
| Define dynamic behavior | mockImplementation() | Use when return values depend on arguments or call order. |
| Define a simple fixed value | mockReturnValue() | Use for deterministic sync collaborators. |
| Reset cross-test state | jest.resetAllMocks() in afterEach | Reset mocks between tests when implementations or call histories are test-specific. Use jest.clearAllMocks() when implementations should remain but call counts should reset. |
Mock at the boundary you own. Do not mock the function under test. If a mock becomes more complex than the behavior it replaces, prefer an in-memory fake or a higher-level integration test.
Treat jest.mock() as the module-level replacement tool; use narrower spies only when the real module should remain loaded.
| Pattern | Correct test style | Failure to avoid |
|---|---|---|
| Promise resolves | await expect(promise).resolves.toEqual(value) | Missing return or await, which lets the test pass before the promise settles. |
| Promise rejects | await expect(promise).rejects.toThrow(Error) | Wrapping an async call in expect(() => asyncFn()).toThrow(). |
| Async arrange/act | const result = await subject() | Mixing done callbacks with promises unless testing callback APIs. |
| Slow integration path | jest.setTimeout(ms) | Raising timeouts for unit tests instead of removing real I/O. |
| Timers | Use fake timers only when the behavior depends on time. | Forgetting to advance timers and flush pending promises. |
Always return promises or use async/await syntax in tests. A test that schedules work without awaiting it is not testing the scheduled behavior.
Use jest.setTimeout() deliberately and document why the test is legitimately slow.
userEvent over fireEvent for realistic user interactions.| Category | Matchers |
|---|---|
| Basic identity and equality | expect(value).toBe(expected), expect(value).toEqual(expected) |
| Truthiness | expect(value).toBeTruthy(), expect(value).toBeFalsy() |
| Numbers | expect(value).toBeGreaterThan(3), expect(value).toBeLessThanOrEqual(3) |
| Strings | expect(value).toMatch(/pattern/), expect(value).toContain('substring') |
| Arrays | expect(array).toContain(item), expect(array).toHaveLength(3) |
| Objects | expect(object).toHaveProperty('key', value) |
| Exceptions | expect(fn).toThrow(), expect(fn).toThrow(Error) |
| Mock functions | expect(mockFn).toHaveBeenCalled(), expect(mockFn).toHaveBeenCalledWith(arg1, arg2) |
## Jest test result
**Status:** implemented | reviewed | blocked
**Target:** `<file, component, function, or class>`
| Area | Decision | Evidence |
| --- | --- | --- |
| Structure | `<placement and describe/it shape>` | `<test path or planned path>` |
| Mocking | `<jest.mock / jest.spyOn / fake / none>` | `<dependency boundary>` |
| Async | `<await/resolves/rejects/timers/not applicable>` | `<specific behavior>` |
| Assertions | `<matcher choices>` | `<key expectations>` |
**Validation**
- `<test command>`: pass | fail | not run
.test.ts, .test.js, .test.tsx, or .test.jsx suffix.resolves and rejects assertions.userEvent.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
6 skills in this plugin
/pester-migrationUpgrade PowerShell Pester test suites across major versions v3 to v4, v4 to v5, and v5 to v6 while preserving test intent. Use when asked to migrate, modernize, or fix *.Tests.ps1 files after a Pester version bump, convert legacy Should or Invoke-Pester syntax, handle Discovery/Run failures, move setup into BeforeAll, migrate mocks, or adopt PesterConfiguration./pester-should-migrationConvert classic Pester v5 `Should -...` assertions to Pester v6 `Should-*` assertion commands while preserving behavior. Use when asked to migrate, convert, rewrite, or modernize `Should -Be`, `Should -Not -Be`, `Should -Throw`, `Should -Invoke`, or other assertions in .Tests.ps1 and PowerShell files./pytest-coverageRun pytest with coverage, read annotated coverage output, identify uncovered lines, and add tests until Python code reaches 100% line coverage. Use this skill when the user asks to run pytest coverage, inspect cov_annotate files, cover missing lines, target a module with --cov, or improve test coverage to 100%./scoutqa-testThis skill should be used when the user asks to "test this website", "run exploratory testing", "check for accessibility issues", "verify the login flow works", "find bugs on this page", or requests automated QA testing. Triggers on web application testing scenarios including smoke tests, accessibility audits, e-commerce flows, and user flow validation using ScoutQA CLI. Use this skill proactively after implementing web application features to verify they work correctly./unit-test-vue-piniaWrite and review unit tests for Vue 3 + TypeScript + Vitest + Pinia codebases. Use when creating or updating tests for components, composables, and stores; mocking Pinia with createTestingPinia; applying Vue Test Utils patterns; and enforcing black-box assertions over implementation details.npx claudepluginhub gbb-acelerators/awesome-harness-primitives --plugin testing-frameworksOther plugins' skills for the same job