Unit testing concepts and common Jest matchers and mocking patterns for testing JavaScript code.
About this set
30 basic cards for JavaScript JavaScript. It opens with "What is unit testing?" and "What does the arrange, act, assert pattern mean?". More College and University decks are listed below.
30 cards · basic cards · AI-written, checked twice. Edit anything.
- What is unit testing?
Show answer
Testing individual functions or modules in isolation to verify they work correctly
- What does the arrange, act, assert pattern mean?
Show answer
Set up test data and state (arrange), execute the code (act), verify the result (assert)
- What is a test suite?
Show answer
A collection of related test cases grouped together
- What is a test case?
Show answer
A single test that checks one specific behavior or output
- What does Jest's toBe() matcher test?
Show answer
Strict equality (===) between two values
- What does Jest's toEqual() matcher test?
Show answer
Deep equality, checking that objects or arrays have the same contents
- What does Jest's toStrictEqual() matcher test?
Show answer
Deep equality with strict type checking, including undefined properties
- What does Jest's toContain() matcher test?
Show answer
Whether an array contains a specific element or a string contains a substring
- What does Jest's toMatch() matcher test?
Show answer
Whether a string matches a given regular expression
- What does Jest's toBeDefined() matcher test?
Show answer
Whether a value is not undefined
- What does Jest's toBeNull() matcher test?
Show answer
Whether a value is exactly null
- What does Jest's toBeUndefined() matcher test?
Show answer
Whether a value is undefined
- What does Jest's toBeTruthy() matcher test?
Show answer
Whether a value evaluates to true in a boolean context
- What does Jest's toBeFalsy() matcher test?
Show answer
Whether a value evaluates to false in a boolean context
- What does Jest's toThrow() matcher test?
Show answer
Whether a function throws an error when called