javascript-typescript-jest▌
github/awesome-copilot · updated Apr 24, 2026
Jest testing best practices for JavaScript and TypeScript projects with mocking, async handling, and React patterns.
- ›Organize tests with descriptive names in nested describe blocks, using .test.ts / .test.js files placed alongside source code or in __tests__ directories
- ›Mock external dependencies with jest.mock() , jest.spyOn() , and mockImplementation() , resetting between tests to prevent state leakage
- ›Handle async code with promises, async/await , and resolves / rejects matchers;
Test Structure
- Name test files with
.test.tsor.test.jssuffix - 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()ormockReturnValue()to define mock behavior - Reset mocks between tests with
jest.resetAllMocks()inafterEach
Testing Async Code
- Always return promises or use async/await syntax in tests
- Use
resolves/rejectsmatchers 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
userEventoverfireEventfor 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)
Discussion
Product Hunt–style comments (not star reviews)- No comments yet — start the thread.
Ratings
4.5★★★★★75 reviews- ★★★★★Charlotte Robinson· Dec 28, 2024
I recommend javascript-typescript-jest for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.
- ★★★★★Ama Malhotra· Dec 28, 2024
Keeps context tight: javascript-typescript-jest is the kind of skill you can hand to a new teammate without a long onboarding doc.
- ★★★★★Chaitanya Patil· Dec 24, 2024
javascript-typescript-jest fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.
- ★★★★★Henry Reddy· Dec 24, 2024
We added javascript-typescript-jest from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.
- ★★★★★Aditi Gill· Dec 24, 2024
javascript-typescript-jest has been reliable in day-to-day use. Documentation quality is above average for community skills.
- ★★★★★Pratham Ware· Dec 20, 2024
Useful defaults in javascript-typescript-jest — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.
- ★★★★★Hana Shah· Dec 16, 2024
Useful defaults in javascript-typescript-jest — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.
- ★★★★★Mia Patel· Dec 8, 2024
We added javascript-typescript-jest from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.
- ★★★★★Aanya Thompson· Dec 4, 2024
I recommend javascript-typescript-jest for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.
- ★★★★★James Anderson· Dec 4, 2024
javascript-typescript-jest fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.
showing 1-10 of 75