expect()
Creates an assertion. Chain with matchers like .toBe(), .toEqual(), .toThrow() to verify values.
Syntax
testing
expect(value).matcher(expected)Example
testing
expect(2 + 2).toBe(4);
expect({ a: 1 }).toEqual({ a: 1 });
expect([1, 2, 3]).toHaveLength(3);
expect("hello").toContain("ell");
expect(null).toBeNull();
expect(fn).toThrow("error message");