toStrictEqual

Bun

Symbol

Matchers.toStrictEqual

toStrictEqual(expected: T): void

Asserts that a value is deeply and strictly equal to what is expected.

There are two key differences from toEqual():

  1. It checks that the class is the same.
  2. It checks that undefined values match as well.
@param expected

the expected value

class Dog {
  type = "dog";
}
const actual = new Dog();
expect(actual).toStrictEqual(new Dog());
expect(actual).toStrictEqual({ type: "dog" }); // fail