Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOMException is not recognized as an Error by throws() and throwsAsync() in AVA v6 #3367

Open
sholladay opened this issue Feb 11, 2025 · 0 comments

Comments

@sholladay
Copy link

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 though error instanceOf Error is true for it.

Minimal reproduction with default config:

import test from 'ava';

test('DOMException should be considered an error', async t => {
	await t.throwsAsync(Promise.reject(new DOMException('an error')));
});

The above test passes on AVA v5 but fails on v6. This applies to both t.throws() and t.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 because error.constructor.name doesn't include "Error"? Would be nice to have some clarification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant