fix: Jest isError handling to work with TypeError (#7251)

This commit is contained in:
Max Schmitt 2021-06-21 21:48:24 +02:00 committed by GitHub
parent 4d0d3924f0
commit 143689e34f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -151,5 +151,5 @@ function isDate(obj: any): obj is Date {
}
function isError(obj: any): obj is Error {
return obj instanceof Error || (obj && obj.__proto__ && obj.__proto__.name === 'Error');
return obj instanceof Error || obj?.__proto__?.name === 'Error' || (obj?.__proto__ && isError(obj.__proto__));
}