javascript-typescript-jest

Solid

Best practices for writing JavaScript/TypeScript tests using Jest, including mocking strategies, test structure, and common patterns.

Testing & QA 34,233 stars 4188 forks Updated today MIT

Install

View on GitHub

Quality Score: 93/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

### 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)` - T...

Details

Author
github
Repository
github/awesome-copilot
Created
11 months ago
Last Updated
today
Language
Python
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category

Testing & QA Listed

javascript-testing-patterns

Implement comprehensive testing strategies using Jest, Vitest, and Testing Library for unit tests, integration tests, and end-to-end testing with mocking, fixtures, and test-driven development. Use when writing JavaScript/TypeScript tests, setting up test infrastructure, or implementing TDD/BDD workflows.

22 Updated 6 days ago
HermeticOrmus
Testing & QA Listed

javascript-testing-patterns

Implement comprehensive testing strategies using Jest, Vitest, and Testing Library for unit tests, integration tests, and end-to-end testing with mocking, fixtures, and test-driven development. Use when writing JavaScript/TypeScript tests, setting up test infrastructure, or implementing TDD/BDD workflows.

0 Updated today
NaetheraS
Testing & QA Solid

javascript-testing-patterns

Implement comprehensive testing strategies using Jest, Vitest, and Testing Library for unit tests, integration tests, and end-to-end testing with mocking, fixtures, and test-driven development. Use when writing JavaScript/TypeScript tests, setting up test infrastructure, or implementing TDD/BDD workflows.

36,222 Updated today
wshobson
Testing & QA Listed

javascript-testing-patterns

Modern JavaScript testing strategies with Jest, Mocha, and testing best practices covering unit testing, integration testing, mocking, async patterns, and DOM testing.

3 Updated today
KaliBellion
Testing & QA Listed

javascript-testing-patterns

Implement comprehensive testing strategies using Jest, Vitest, and Testing Library for unit tests, integration tests, and end-to-end testing with mocking, fixtures, and test-driven development. Use when writing JavaScript/TypeScript tests, setting up test infrastructure, or implementing TDD/BDD workflows.

335 Updated today
aiskillstore