FlashKeepers

JavaScript · JavaScript

JavaScript Testing Fundamentals

Unit testing concepts and common Jest matchers and mocking patterns for testing JavaScript code.

30 cards · basic cards · AI-written, checked twice. Edit anything.

Study this set free Look inside first Get FlashKeepers for iPhone
What is unit testing?
Testing individual functions or modules in isolation to verify they work correctly
What does the arrange, act, assert pattern mean?
Set up test data and state (arrange), execute the code (act), verify the result (assert)
What is a test suite?
A collection of related test cases grouped together
What is a test case?
A single test that checks one specific behavior or output
What does Jest's toBe() matcher test?
Strict equality (===) between two values
What does Jest's toEqual() matcher test?
Deep equality, checking that objects or arrays have the same contents
What does Jest's toStrictEqual() matcher test?
Deep equality with strict type checking, including undefined properties
What does Jest's toContain() matcher test?
Whether an array contains a specific element or a string contains a substring
What does Jest's toMatch() matcher test?
Whether a string matches a given regular expression
What does Jest's toBeDefined() matcher test?
Whether a value is not undefined
What does Jest's toBeNull() matcher test?
Whether a value is exactly null
What does Jest's toBeUndefined() matcher test?
Whether a value is undefined
What does Jest's toBeTruthy() matcher test?
Whether a value evaluates to true in a boolean context
What does Jest's toBeFalsy() matcher test?
Whether a value evaluates to false in a boolean context
What does Jest's toThrow() matcher test?
Whether a function throws an error when called

15 more cards in the app