-
Notifications
You must be signed in to change notification settings - Fork 74
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
Assert errors #20
Comments
Can't you use something like this?
|
Nop, foo is asynchronous, it never throws the error, it is returned as an argument. |
|
exports.ifError = function (err) {
if (err) throw err;
} We can simply use the native function but it'd be good if it is integrated into var assert = require('assert');
it('foo', function(done) {
foo(function (err) {
assert.ifError(err);
done()
});
}); |
the reason Code doesn't throw is to continue the tests even if 1 fails. If you want the stack trace of an actual error you can use https://github.com/hapijs/hoek#displaystackslice ? |
Well, I need the stack and the error description. If an error occurs I simply want to throw the error. |
Why would you want to throw in your test suite? |
To see why |
Shouldn't the stacktrace be shown anyway? |
|
That's because Lab catches errors so the process does not crash and all of your tests can run. The same behavior should be seen if you explicitly throw an exception. |
This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions. |
How can we check that an error must not exist but if it exists, throw the error? This is for asynchronous functions. Right now I do:
But when the function returns an error, lab just tells that
err
exists when it should not, the stacktrace of the error is not printed.I'd like to have a function with the identical behaviour of node's built-in assert.ifError(), something like:
The text was updated successfully, but these errors were encountered: