-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Check assertion message is a string #1125
Comments
What error occured in your promise? |
console.log('------>', test.error); ------> { name: 'AssertionError',
actual: false,
expected: false,
operator: 'fail',
message:
{ name: 'Error',
stack: 'Error: ENOENT: no such file or directory, open \'app.png\'\n at Error (native)',
message: 'ENOENT: no such file or directory, open \'app.png\'',
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: 'app.png' },
generatedMessage: false,
stack: 'AssertionError: Error: ENOENT: no such file or directory, open \'app.png\'\n generateSprite.then.then.catch.err (test/sprite.spec.js:103:11)\n ' } test.message is an Error object. |
It eventually looks like caused by calling However I think it's good to support both error message and error object. x.fail = function (msg) {
if (msg instanceof Error) {
msg = msg.message
}
msg = msg || 'Test failed via t.fail()';
test(false, create(false, false, 'fail', msg, x.fail));
}; |
@creeperyang @avajs/core perhaps it would be useful to typecheck that argument? |
@novemberborn Agree, a check wouldn't hurt. |
👍 |
👍 much better. |
Cool. We're now looking to add a typecheck for the optional assertion message parameter, ensuring it's a string if it is provided. |
May I take on this as a gentle step into AVA. One question: For uniformity, would it not make sense to apply same check in other sibling functions such In that case the check can be centralised as a helper and invoked in all sibling functions where it is needed. |
@leewaygroups yes please! Thank you! |
To clarify, per #1831 (comment), we want to type check the |
(See #1125 (comment), @novemberborn)
[email protected], [email protected]
When I run test, sometimes I get this error:
And I found this maybe caused by:
The text was updated successfully, but these errors were encountered: