馃摑 Disallow using equality matchers on error types.
馃挱 This rule requires type information.
When comparing errors, toEqual and toStrictEqual will only compare the
message properties, meaning tests can pass even if the errors are of different
types.
Instead, it is better to use toThrow which does check the error type along
with its message.
This rule warns when toEqual and toStrictEqual is used with an Error type.
The following patterns are considered warnings:
expect(new AggregateError([], expect.any(String))).toEqual(
new Error(expect.any(String)),
);
expect(new Error('hello world')).toStrictEqual('hello sunshine');The following patterns are not considered warnings:
expect(() => throw new AggregateError([], expect.any(String))).toThrow(new Error(expect.any(String)));
expect(() => throw new Error('hello world')).toThrow('hello sunshine');