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

Using mocha.throwError for better async error handling #222

Closed
wants to merge 3 commits into from

Conversation

jpbochi
Copy link

@jpbochi jpbochi commented Dec 8, 2013

This is a follow up to mochajs/mocha#985

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 1baa0f8 on jpbochi:async-error-handling into 0e560c6 on chaijs:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling b127b01 on jpbochi:async-error-handling into 0e560c6 on chaijs:master.

@jpbochi
Copy link
Author

jpbochi commented Dec 8, 2013

Travis is a little crazy. It passes as a PR for chai, but fails as a branch on my fork.

@jpbochi
Copy link
Author

jpbochi commented Jan 16, 2014

@travisjeffery @visionmedia Hey, have you got time to take a look at this PR?

@logicalparadox
Copy link
Member

Chai strives to remain test runner agnostic. Inclusion of this PR would violate that principle. Our plugin api is robust enough to have this implemented as a plugin.

Furthermore, this PR implements this for the assert interface but ignores the chainable interfaces (expect, should).

@diversario
Copy link

So, this idea is dead? Is there a plugin or anything that implements this?

@jpbochi
Copy link
Author

jpbochi commented Aug 6, 2015

@diversario I guess I was just blocked, and I never got time to try this as a plugin as it was suggested. Interesting enough, making the necessary change on mocha was easier.

@diversario
Copy link

😑Lame.
So, you have some workaround that you use yourself for this?

@jpbochi
Copy link
Author

jpbochi commented Aug 6, 2015

I've been away from node.js for a while, so I don't remember the details any more.

I was reviewing some of my stale code now. In my case, I think the async code was all inside a jQuery.Deferred object. Apparently, my solution was to make sure mocha's done callback for sync tests by passing done to the deferred.always. Here's an example: https://github.com/jpbochi/duelo/blob/master/tests/api/game_tests.js#L21-L28

As I said, I don't remember exactly. This .always(done.bind(null, null)); might be there for another reason.

hope it helps.

@diversario
Copy link

Thanks, @jpbochi.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants