Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Only skip current suite if error in beforeEach or beforeAll [Fix #581] #664

Closed
wants to merge 6 commits into
from

Conversation

Projects
None yet
5 participants

dansitu commented Nov 20, 2012

A failed beforeEach or beforeAll hook will now only cause the current suite to be skipped, rather than terminating the entire run.

Fix for #581

Daniel Imrie-Situnayake added some commits Nov 19, 2012

Daniel Imrie-Situnayake Test case for hook fail 24a8f45
Daniel Imrie-Situnayake Correct behaviour on failure of beforeAll hook; don't run any more te…
…sts from the current suite, but carry on with other suites as normal.
81f6443
Daniel Imrie-Situnayake Also return from Runner.hook if hook experiences an 'error'. 559e579
Daniel Imrie-Situnayake If a beforeEach hook fails, don't run the following test. 0ae96d2
Daniel Imrie-Situnayake Make'd mocha.js 9d0d868
Daniel Imrie-Situnayake Revert "Make'd mocha.js"
This reverts commit 9d0d868.
5ce7d02
Contributor

tj commented Nov 29, 2012

this seems to mostly work, however if you have a beforeEach the nested suites will still execute beforeEach, even though a parent one has failed, ill see if i can get that working quickly here

dansitu commented Nov 29, 2012

Oops - sorry, good catch.

On Nov 28, 2012, at 4:08 PM, TJ Holowaychuk notifications@github.com wrote:

this seems to mostly work, however if you have a beforeEach the nested suites will still execute beforeEach, even though a parent one has failed, ill see if i can get that working quickly here


Reply to this email directly or view it on GitHub.

Contributor

piuccio commented Mar 20, 2013

@dansitu Any update on this pull request?

I'm having an issue writing my custom reporter because when there's an error inside hooks, the runner doesn't emit the hook end event.

dansitu commented Mar 20, 2013

I was in a hurry and didn't have time to make the fix @visionmedia suggested. @piuccio, maybe you'll have better luck?

Contributor

piuccio commented Mar 20, 2013

I'll see if I can work on it

Any reason to not just blow away the children suites of the current suite when failHook is called?

Runner.prototype.failHook = function(hook, err){
  this.fail(hook, err);
  this.suites.suite = [];
  this.emit('hook end', hook);
 };

This solves for the issue with beforeEach and nested suites.

Contributor

travisjeffery commented Dec 2, 2013

fixed by #1043

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment