skills/javascript-typescript-jest/SKILL.md
Best practices for writing JavaScript/TypeScript tests using Jest, including mocking strategies, test structure, and common patterns.
npx skillsauth add shysssthanhtri/AI-tools javascript-typescript-jestInstall 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.
.test.ts or .test.js suffix__tests__ directorydescribe('Component/Function/Class', () => { it('should do something', () => {}) })jest.mock() for module-level mocksjest.spyOn() for specific function mocksmockImplementation() or mockReturnValue() to define mock behaviorjest.resetAllMocks() in afterEachresolves/rejects matchers for promisesjest.setTimeout()userEvent over fireEvent for more realistic user interactionsexpect(value).toBe(expected), expect(value).toEqual(expected)expect(value).toBeTruthy(), expect(value).toBeFalsy()expect(value).toBeGreaterThan(3), expect(value).toBeLessThanOrEqual(3)expect(value).toMatch(/pattern/), expect(value).toContain('substring')expect(array).toContain(item), expect(array).toHaveLength(3)expect(object).toHaveProperty('key', value)expect(fn).toThrow(), expect(fn).toThrow(Error)expect(mockFn).toHaveBeenCalled(), expect(mockFn).toHaveBeenCalledWith(arg1, arg2)testing
Execute an existing Jira ticket implementation plan phase by phase. Use when asked to "work on ticket CM-1234", "implement the plan for CM-1234", "start working on the plan", or "execute the next phase". Reads the plan from docs/<ticket-id>/plan.md, captures a pre-implementation full test baseline in plan/progress docs, presents each phase for user approval before coding, updates progress after each phase, and operates inside the dedicated git worktree. After the last phase is committed, runs the full test suite, fixes regressions (skipping known pre-existing failures), then presents a full change summary for user review and creates a GitHub draft PR using the create-draft-pr skill.
tools
Generate a complete MCP server project in TypeScript with tools, resources, and proper configuration
tools
Use when starting work on a Jira ticket. Fetches ticket details via Atlassian MCP (for branch naming and a local story snapshot), creates an isolated git worktree with branch feature/<ticket-id>-<slug>-<platform>, and writes docs/<ticket-id>/<ticket-id>.md in the worktree.
documentation
Create a work plan for a Jira ticket. Use when asked to plan work, create a plan for a ticket, break down a Jira issue, or prepare implementation steps for a Jira ticket ID like CM-1234. Reads local ticket details, deeply analyzes requirements and root causes, proposes up to three optimized solutions (not workarounds) with pros and cons, asks the user to choose, then finalizes the plan with that choice under docs/<ticket-id>/.