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

When there is beforeEach hook and test fails in async callback, it aborts other tests and error messages report wrong blocks #183

Closed
petejkim opened this issue Dec 30, 2011 · 2 comments

Comments

@petejkim
Copy link

describe('mocha tests', function() {
  beforeEach(function() {
    // there is beforeEach hook
  });

  it('should go to the next test when it fails (outside callback)', function(done){
    throw new Error('the other test should still run');
    done();
  });

  it('should go to the next test when it fails (inside callback)', function(done) {
    setTimeout(function() {
      throw new Error('the other test should still run');
      done();
    }, 0);
  });

  it('should get to this test', function(done) {
    throw new Error('YES! This test still runs!');
    done();
  });
});

Expected output:

...

  ✖ 3 of 3 tests failed:

  0) mocha tests should go to the next test when it fails (outside callback):
     Error: the other test should still run
      at ...

  1) mocha tests should go to the next test when it fails (inside callback):
     Error: the other test should still run
      at ...

  2) mocha tests should get to this test:
     Error: YES! This test still runs!
      at ...

Actual output:

..

  ✖ 2 of 3 tests failed:

  0) mocha tests should go to the next test when it fails (outside callback):
     Error: the other test should still run
      at ...

  1) mocha tests "before each" hook:
     Error: the other test should still run
      at ...

Notice that the test is aborted and the error block reporting for the second error is also wrong.

Related Issue: Issue 94

@tj
Copy link
Contributor

tj commented Dec 30, 2011

interesting thanks for the report ill look into it in a min

@tj tj closed this as completed in 800840e Dec 30, 2011
@petejkim
Copy link
Author

awesome, thanks!!!

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

No branches or pull requests

2 participants