-
Notifications
You must be signed in to change notification settings - Fork 28
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' does not have error until next tick #8
Comments
Can you show me some code and maybe a screenshot? |
here's a test: test('handles error immediately', function (t) {
t.plan(2);
var mockTap = [
"TAP version 13",
"# is true",
"ok 1 true value",
"ok 2 true value",
"not ok 3 strings match",
" ---",
" operator: equal",
" expected: 'you'",
" actual: 'me'",
" at: Test.<anonymous> (http://localhost:9966/index.js:8:5)",
" ...",
"not ok 15 plan != count",
" ---",
" operator: fail",
" expected: 4",
" actual: 3",
" ...",
"",
"1..15",
];
var p = parser();
// works
p.on('output', function (output) {
t.deepEqual(output.fail[0].error.expected, 'you')
})
// does not work
// p.on('assert', function (assert) {
// t.deepEqual(assert.error.expected, 'you')
// });
mockTap.forEach(function (line) {
p.write(line + '\n');
});
p.end();
}); If you comment out that assertion you will get an error: /projects/oss/tap-out/test/index.js:494
t.deepEqual(assert.error.expected, 'you')
^
TypeError: Cannot read property 'expected' of undefined |
Hmm, thinking a bit more about this. Maybe it is the intended result, since by the time the parser reaches "assert" it still has no information about
Anyways, I'm going to render errors at the bottom of the console (after |
I'll still investigate on the best way to handle this. Feel free to submit a PR if you get anxious. |
I'll go ahead and close this and we can revisit if it causes more issues for you. |
k 👍 |
I've noticed the callback to
assert
is triggered too early. It has anerror
object, but the properties are all undefined until the next tick. Have you run into this before?The text was updated successfully, but these errors were encountered: