-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
DOMException is not recognized as an Error by throws() and throwsAsync() in AVA v6 #3367
Comments
`import test from 'ava'; test('DOMException should be considered an error', async t => { |
We don't use the assertion |
See https://github.com/avajs/ava/blob/main/docs/08-common-pitfalls.md#error-edge-cases (which isn't linked to from the assertions documentation, so that's not helpful).
How is |
It comes from |
var error;fetch('https://novemberborn.net', {signal: AbortSignal.abort() }).catch(e=>{error=e})
// Wait for promise…
util.types.isNativeError(error) // false! Looking at https://developer.mozilla.org/en-US/docs/Web/API/DOMException I don't think a However it is included as a global in Node.js, so I think That said, the implementation in Node.js doesn't look to be spec-compatible, e.g. nodejs/node#57372 suggests the errors can't be cloned / sent between workers. I think an |
What's the reason for not treating anything where |
You'll have to look at the commit for all the details, but if I recall we had some heuristics and switched to a built-in method. Not at my computer currently but I don't think |
OK so
The removal of |
In the Ky tests, we have a simple assertion that a Node.js
DOMException
is thrown when a request is aborted. In AVA v5, this assertion works as expected. However, beginning with AVA v6,DOMException
seems to no longer be detected as an error, even thougherror instanceOf Error
istrue
for it.Minimal reproduction with default config:
The above test passes on AVA v5 but fails on v6. This applies to both
t.throws()
andt.throwsAsync()
.As an aside, the docs are not very clear on what is considered "an error". I always assumed it meant the object had to be an
instanceof Error
, but at least in AVA v6, this seems to not be the case. Is it becauseerror.constructor.name
doesn't include "Error"? Would be nice to have some clarification.The text was updated successfully, but these errors were encountered: