Unit, integration and async testing in JavaScript and Python: matchers, mocking, fixtures, parametrisation, snapshots, coverage and CI config.
Preview — first 3 of 118 cards
What is the basic test structure in Jest?
describe() groups related tests, test() or it() defines a single test case. expect() holds the actual value and a matcher asserts the expected value.
describe('Calculator', () => {
test('adds numbers', () => {
expect(1 + 2).toBe(3);
});
it('subtracts', () => {
expect(5 - 2).toBe(3);
});
});
What is the difference between test and it?
They are aliases with identical behavior. it reads more like natural language; test is more explicit. Choose one style and stay consistent.
How do beforeEach and afterEach work?
beforeEach runs before every test in the describe block; afterEach runs after every test. Use them for setup and teardown such as resetting state or clearing mocks.
describe('User', () => {
let user;
beforeEach(() => { user = createUser(); });
afterEach(() => { user = null; });
test('has name', () => expect(user.name).toBe('Ada'));
});
115 more cards in this sheet
Unlock the Backend, Databases & AI bundle — ₹399
One-time payment. Unlocks this sheet and 14 other sheets in the bundle, plus a typeset PDF of each.
Unlock the bundle
See all bundles
Or get all 76 sheets for ₹999 — one payment, every future sheet included.