Update ava to 4.3.3

The [release notes](https://github.com/avajs/ava/releases/tag/v4.3.3)
mention compatibility with Node 18.8.
This commit is contained in:
Henry Mercer 2022-09-02 18:02:07 +01:00
parent 21530f507f
commit bea5e4b220
160 changed files with 2647 additions and 2263 deletions

22
node_modules/ava/lib/assert.js generated vendored
View file

@ -106,10 +106,15 @@ function validateExpectations(assertion, expectations, numberArgs) { // eslint-d
});
}
if (hasOwnProperty(expectations, 'message') && typeof expectations.message !== 'string' && !(expectations.message instanceof RegExp)) {
if (
hasOwnProperty(expectations, 'message')
&& typeof expectations.message !== 'string'
&& !(expectations.message instanceof RegExp)
&& !(typeof expectations.message === 'function')
) {
throw new AssertionError({
assertion,
message: `The \`message\` property of the second argument to \`t.${assertion}()\` must be a string or regular expression`,
message: `The \`message\` property of the second argument to \`t.${assertion}()\` must be a string, regular expression or a function`,
values: [formatWithLabel('Called with:', expectations)],
});
}
@ -230,6 +235,19 @@ function assertExpectations({assertion, actual, expectations, message, prefix, s
});
}
if (typeof expectations.message === 'function' && expectations.message(actual.message) === false) {
throw new AssertionError({
assertion,
message,
savedError,
actualStack,
values: [
formatWithLabel(`${prefix} unexpected exception:`, actual),
formatWithLabel('Expected message to return true:', expectations.message),
],
});
}
if (typeof expectations.code !== 'undefined' && actual.code !== expectations.code) {
throw new AssertionError({
assertion,