It seems like last changes in toThrow (https://github.com/facebook/jest/pull/7621) broke a behaviour uses were relying on in Jest 23.
We can expect toThrow to behave like toEqual on the thrown error, but that's not the case anymore.
Steps to reproduce the behavior:
Run this test with Jest 23 and Jest 24.0.0-alpha.13:
class CustomError { // not extending Error!
constructor(message) {
this.message = message;
}
}
function throwError() {
throw new CustomError('foo');
}
test('toThrow', () => {
expect(throwError).toThrowError(new CustomError('foo'));
});
test('toEqual', () => {
try {
throwError();
} catch (e) {
expect(e).toEqual(new CustomError('foo'));
return;
}
throw new Error('Expected error here');
});
No errors. Those two tests should be equivalent.
Also, I found the error message a bit confusing:

(before anyone picks this up, @pedrottimark is working on it)
I could repro this asymmetry with non-errors, but there might be more cases like that.
Most helpful comment
(before anyone picks this up, @pedrottimark is working on it)