Fix index-as-message bug in assertArray

As `assertArray` previously called the assertion
function in a `forEach(assertion)`, the index was
passed as the custom message. This commit fixes
this bug by passing down the `message` argument
to the assertion function.

A `@ts-expect-error` comment was added to due to
"Assertions require every name in the call target
to be declared with an explicit type
annotation.".
This commit is contained in:
Martin Eneqvist 2024-09-06 09:56:14 +02:00
parent ab85d9bca9
commit d77be18d42
2 changed files with 10 additions and 3 deletions

View file

@ -773,6 +773,10 @@ test('is.array', t => {
x[0]?.toFixed(0);
}
});
t.throws(() => {
assert.array([1, '2'], assert.number, 'Expected numbers');
}, {message: /Expected numbers/});
});
test('is.function', t => {