.cursor/skills/qa-jest-writer/SKILL.md
Generate Jest unit and integration tests for TypeScript/JavaScript projects with jest.mock, snapshots, code coverage, and describe/it patterns.
npx skillsauth add AZANIR/qa-skills qa-jest-writerInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Write Jest unit and integration tests from test case specifications (Phase 2 output). Transform structured test cases into executable TypeScript/JavaScript tests using Jest's describe/it patterns, mocking, snapshots, and coverage tooling.
| Type | Scope | Focus | | ---- | ----- | ----- | | Unit | Isolated function/class testing | Single unit, mocked dependencies | | Integration | Module interaction, service layer | Real or partial integration, fewer mocks |
{module}.test.ts or {module}.spec.tsUses Context7 MCP to fetch current Jest documentation when needed. Query for Jest API, matchers, or configuration to ensure generated tests align with latest Jest behavior.
| Pattern | Use Case |
| ------- | -------- |
| describe / it / test | Group and define test cases |
| beforeEach / afterEach | Setup and teardown per test |
| jest.mock() | Mock entire modules (hoisted) |
| jest.spyOn() | Spy on object methods |
| Snapshot testing | UI components, serializable output |
| test.each | Parameterized / table-driven tests |
| async/await, done | Async testing |
| Custom matchers | Domain-specific assertions |
| Assertion | Use |
| --------- | --- |
| toBe | Strict equality (===) |
| toEqual | Deep equality |
| toMatchObject | Partial object match |
| toThrow | Error thrown |
| toHaveBeenCalledWith | Mock call arguments |
| resolves / rejects | Promise outcomes |
See references/assertions.md for full reference.
moduleNameMapper, transform, coverage@/ → src/)See references/config.md for configuration guide.
{module}.test.ts — Preferred (aligns with Jest default){module}.spec.ts — Alternative (common in Angular/Vue)Place tests next to source (__tests__/ or colocated) or in tests/ per project convention.
Can do (autonomous):
Cannot do (requires confirmation):
Will not do (out of scope):
references/patterns.md — Unit structure, mocking strategies, async, snapshots, error testingreferences/assertions.md — Complete Jest assertion reference by categoryreferences/config.md — jest.config, tsconfig paths, coverage, setupFilesreferences/best-practices.md — Anti-patterns, AAA, isolation, descriptive names| Symptom | Likely Cause | Fix |
| ------- | ------------ | --- |
| Module not found | Path/alias mismatch | Check moduleNameMapper in jest.config, tsconfig paths |
| Mock not working | Hoisting / import order | Use jest.mock() at top of file, before imports |
| Timeout | Async not resolved | Increase jest.setTimeout(), ensure promises resolve |
| Snapshot drift | Intentional change | Run jest -u to update; verify change is correct |
| Coverage gaps | Missing branches | Add tests for error paths, edge cases |
| Spy not called | Wrong target or timing | Verify spy on correct object, call after setup |
tools
Analyze OpenAPI/Swagger spec (JSON or YAML) against existing test files and generate an HTML coverage report with QA automation tasks. Use when user provides an OpenAPI spec file and wants to know test coverage status.
testing
Universal QA plan generator supporting 10 plan types including test plans, sprint plans, regression plans, release plans, UAT plans, performance plans, migration plans, onboarding plans, and custom plans.
development
Generate consumer-driven contract tests using Pact for JavaScript and Python to verify microservice API compatibility between consumer and provider.
development
Master skill coordinating all QA skills through pipeline modes (full-cycle, docs-only, testcases-only, write-tests, report), formalized handoff chains, scheduler rules, and framework/language selection based on project context.