
Javascript Typescript Jest
Install this skill when your agent writes or refactors Jest tests for JavaScript or TypeScript so mocks, async patterns, and structure stay consistent.
Overview
javascript-typescript-jest is an agent skill for the Ship phase that applies Jest and React Testing Library best practices when writing or refactoring JavaScript and TypeScript tests.
Install
npx skills add https://github.com/github/awesome-copilot --skill javascript-typescript-jestWhat is this skill?
- Covers test file layout (.test.ts/js), describe/it structure, and nested organization
- Documents jest.mock, jest.spyOn, mockImplementation, and afterEach reset patterns
- Async guidance: async/await, resolves/rejects matchers, and jest.setTimeout
- Snapshot testing discipline and React Testing Library accessibility-first queries
- Recommends co-located tests or dedicated __tests__ directories
Adoption & trust: 11k installs on skills.sh; 34.6k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You want agent-generated tests that mock dependencies correctly, handle async code, and follow a consistent structure instead of brittle one-off specs.
Who is it for?
Solo builders using Jest (or a Jest-compatible setup) who delegate test creation or fixes to an coding agent on SaaS, CLI, or API codebases.
Skip if: Teams standardized on Vitest-only, Playwright-only E2E, or non-JS stacks where Jest patterns do not apply.
When should I use this skill?
Writing or refactoring JavaScript/TypeScript tests with Jest, including mocks, async code, snapshots, or React components.
What do I get? / Deliverables
New or updated test files follow Jest naming, mocking, async, snapshot, and RTL patterns that are ready to run in your existing test runner.
- .test.ts or .test.js files with describe/it suites
- Mock and spy setup aligned with SKILL guidance
Recommended Skills
Journey fit
Automated test authoring and Jest conventions sit in Ship because they gate confidence before release, not during initial feature coding. The testing subphase is where unit and integration specs, snapshots, and React Testing Library patterns are defined and maintained.
How it compares
Use for procedural Jest/Rtl conventions instead of asking the model to invent mocking style on each task.
Common Questions / FAQ
Who is javascript-typescript-jest for?
Indie developers and small teams shipping JS/TS products who want their agent to write tests that match common Jest and React Testing Library practice.
When should I use javascript-typescript-jest?
Use it in Ship (testing) when adding unit tests, fixing flaky async specs, or introducing RTL for components; it is phase-specific to test authoring, not product discovery.
Is javascript-typescript-jest safe to install?
It is documentation-style guidance without built-in shell or network calls; review the Security Audits panel on this Prism page before installing any skill from the catalog.
SKILL.md
READMESKILL.md - Javascript Typescript Jest
### Test Structure - Name test files with `.test.ts` or `.test.js` suffix - Place test files next to the code they test or in a dedicated `__tests__` directory - Use descriptive test names that explain the expected behavior - Use nested describe blocks to organize related tests - Follow the pattern: `describe('Component/Function/Class', () => { it('should do something', () => {}) })` ### Effective Mocking - Mock external dependencies (APIs, databases, etc.) to isolate your tests - Use `jest.mock()` for module-level mocks - Use `jest.spyOn()` for specific function mocks - Use `mockImplementation()` or `mockReturnValue()` to define mock behavior - Reset mocks between tests with `jest.resetAllMocks()` in `afterEach` ### Testing Async Code - Always return promises or use async/await syntax in tests - Use `resolves`/`rejects` matchers for promises - Set appropriate timeouts for slow tests with `jest.setTimeout()` ### Snapshot Testing - Use snapshot tests for UI components or complex objects that change infrequently - Keep snapshots small and focused - Review snapshot changes carefully before committing ### Testing React Components - Use React Testing Library over Enzyme for testing components - Test user behavior and component accessibility - Query elements by accessibility roles, labels, or text content - Use `userEvent` over `fireEvent` for more realistic user interactions ## Common Jest Matchers - Basic: `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)`