Test Basics & Matchers. Structure. // Organizing tests describe('UserService', () => { describe('create', () => { it('should create a user with valid data', () => { ... }); it('should throw when email is invalid', () => …
ReadMocking & Advanced. jest.fn() — Mock Functions. const mockFn = jest.fn(); // Set return value mockFn.mockReturnValue(42); mockFn.mockReturnValueOnce(10).mockReturnValueOnce(20); // Async mockFn.mockResolvedValue({ id: 1,…
ReadJest Interview Questions. Q: What is the difference between unit, integration, and e2e tests?. Unit — test a single function/class in isolation; all dependencies are mocked. Fast, numerous, pinpoint failures.. Integratio…
ReadSave this stack to your personal DevRecall — add your own notes, track what you're learning, and share what you know with the community.
Get started — free forever