Common Matchers in Jest

From the Jest cheat sheet · Matchers · verified Jul 2026

Common Matchers

Most frequently used Jest matchers for assertions

javascript
// Equality
expect(2 + 2).toBe(4)              // Exact equality ===
expect({name: 'jest'}).toEqual({name: 'jest'}) // Deep equality

// Truthiness
expect(value).toBeTruthy()
expect(value).toBeFalsy()
expect(value).toBeNull()
expect(value).toBeUndefined()
expect(value).toBeDefined()

// Numbers
expect(2 + 2).toBeGreaterThan(3)
expect(2 + 2).toBeGreaterThanOrEqual(4)
expect(2 + 2).toBeLessThan(5)
expect(0.1 + 0.2).toBeCloseTo(0.3) // For floating point

// Strings
expect('team').toMatch(/I/)
expect('Christoph').toMatch('stop')

// Arrays and Iterables
expect(['Alice', 'Bob']).toContain('Alice')
expect(new Set(['Alice', 'Bob'])).toContain('Alice')
expect(['Alice', 'Bob']).toHaveLength(2)
💡 Use toEqual for objects/arrays, toBe for primitives
⚡ toBeCloseTo is essential for floating point comparisons
📌 toStrictEqual checks undefined properties and array holes
🟢 Combine matchers with .not for negative assertions
matchersassertions

Continue with Jest

Save the full cheat sheet or work through every related task.

More Jest tasks

Back to the full Jest cheat sheet