-
-
Notifications
You must be signed in to change notification settings - Fork 307
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
Add "onFailure" listener to test harness. #408
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! We'll also need some tests to cover this hook.
lib/results.js
Outdated
else self.fail ++ | ||
else { | ||
self.emit("fail"); | ||
self.fail ++; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could the sync emission fail? it seems like we should increment self.fail
first.
@ljharb , thanks for the feedback! I'm still having trouble coming up with a way of testing for the failure event that doesn't cause the test to fail. |
test/onFailure.js
Outdated
var tape = require("../"); | ||
const t = tap.test("on failure", {timeout: 1000}, function (tt) { | ||
tt.plan(1); | ||
tape.onFailure(function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could this add an onFinish
listener as well that fails?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ljharb, i don't quite understand your comment.
This test does, in fact, fail. That is, for the "outer test" to pass, the "inner test" must fail, and this failure propagates. I wonder if you, or anyone else might have an idea about how to get around this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, what I mean is, add something like tape.onFinish(function () { tt.fail(); })
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ljharb I couldn't quite get the method that you mentioned to work, though I was able to get a test working after a while. Hopefully that does it. Thanks again for the help and feedback!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
It'd be great to rebase this down to a single commit; if you're unable, I can do it for you prior to merging.
Is anything else needed for this pull request? |
@lastmjs, i think this is ready, but I'm happy to make any changes that would get this into the next release soon. |
- [New] use `process.env.NODE_TAPE_OBJECT_PRINT_DEPTH` for the default object print depth (#420) - [New] Add "onFailure" listener to test harness (#408) - [Fix] fix stack where actual is falsy (#400) - [Fix] normalize path separators in stacks (#402) - [Fix] fix line numbers in stack traces from inside anon functions (#387) - [Fix] Fix dirname in stack traces (#388) - [Robustness] Use local reference for clearTimeout global (#385) - [Deps] update `function-bind`
Adds an onFinish listener to test harness as discussed here: #367 (comment)