Skip to content
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

Merged
merged 1 commit into from
Dec 15, 2017
Merged

Add "onFailure" listener to test harness. #408

merged 1 commit into from
Dec 15, 2017

Conversation

johnhenry
Copy link
Contributor

Adds an onFinish listener to test harness as discussed here: #367 (comment)

Copy link
Collaborator

@ljharb ljharb left a 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 ++;
Copy link
Collaborator

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.

@johnhenry
Copy link
Contributor Author

@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.

var tape = require("../");
const t = tap.test("on failure", {timeout: 1000}, function (tt) {
tt.plan(1);
tape.onFailure(function() {
Copy link
Collaborator

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?

Copy link
Contributor Author

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?

Copy link
Collaborator

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(); })

Copy link
Contributor Author

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!

Copy link
Collaborator

@ljharb ljharb left a 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.

@johnhenry johnhenry changed the title Add "onFinish" listener to test harness. Add "onFailure" listener to test harness. Nov 15, 2017
@lastmjs
Copy link

lastmjs commented Dec 15, 2017

Is anything else needed for this pull request?

@johnhenry
Copy link
Contributor Author

@lastmjs, i think this is ready, but I'm happy to make any changes that would get this into the next release soon.

@ljharb ljharb merged commit 0e870c6 into tape-testing:master Dec 15, 2017
ljharb added a commit that referenced this pull request Feb 19, 2018
 - [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`
@ljharb ljharb mentioned this pull request Mar 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants