Closed
Description
Description
The current API:
.throws(function|promise, [error, [message]])
only allows to define constructor of the error and requires to test message separately, e.g.
const error = await t.throws(createReservation(undefined, parameters, context), UserError);
t.true(error.message === 'Ticket selection cannot be empty.');
By the way,
.throws(function|promise, [error, [message]])
is slightly misleading.
At first I thought the third parameter is the error message, i.e.
t.throws(createReservation(undefined, parameters, context), 'Ticket selection cannot be empty.');
.
It would be convenient to be able to construct the error as such:
await t.throws(createReservation(undefined, parameters, context), new UserError(Ticket selection cannot be empty.));
In such case, ava would need to check that the constructor of the object and the message match.
Metadata
Metadata
Assignees
Labels
No labels