method
test.MatchersBuiltin.toStrictEqual
expected: T
): void;
Asserts that a value is deeply and strictly equal to what is expected.
There are two key differences from toEqual():
- It checks that the class is the same.
- It checks that
undefinedvalues 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