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; set timeouts for slow tests Test React components with React Testing Library, querying by accessibility roles and labels, and using userEvent for realistic interactions Includes 20+ common matchers covering truthiness, numbers, strings, arrays, objects, exceptions, and mock function assertions
Similar popular skills
Related neighbors and high-traction skills in the same topics — useful to compare before installing.