Closed mattdesl closed 9 years ago
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 error
. Maybe a solution would be:
error
has been parsederror
object to the event of 'assert'
to avoid confusionAnyways, I'm going to render errors at the bottom of the console (after output
) so this issue is no longer such a big deal. :smile:
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 :+1:
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?