Assertions
Built-in expect() assertions.
1 min readEdit this page
Assertions
expect(value).toBe(42)
expect(value).toEqual({ name: 'Tariq' })
expect(value).toBeTruthy()
expect(value).toBeNull()
expect(value).not.toBe(0)
expect(arr).toHaveLength(3)
expect(arr).toContain('item')
expect(obj).toHaveProperty('name')
expect(str).toMatch(/pattern/)
expect(() => fn()).toThrow()
await expect(promise).rejects.toThrow()