Crash Courses · Basic
Automated Testing with Jest
Unit tests, mocking, coverage
15 min read+200 XP on completionCert: Quality Assurance
Tap any word in the text below to start reading from there.
# Automated Testing with Jest
Structure
describe groups tests. it (or test) defines a single test case. expect creates the assertion.
Common Matchers
toBe for strict equality. toEqual for deep equality on objects and arrays. toContain for arrays and strings. toThrow for expected errors. toBeTruthy and toBeFalsy.
Mocking
jest.mock replaces an entire module. jest.fn creates a mock function. mockResolvedValue sets the return value for async mocks.
Reading progress
0% read
In this module
describe
it / test
expect
mock
0%