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

afterEach conditional error hook breaks stats and error reporting #3345

Closed
4 tasks done
fgarcia opened this issue Apr 22, 2018 · 2 comments · Fixed by #3362
Closed
4 tasks done

afterEach conditional error hook breaks stats and error reporting #3345

fgarcia opened this issue Apr 22, 2018 · 2 comments · Fixed by #3362
Labels
type: bug a defect, confirmed by a maintainer

Comments

@fgarcia
Copy link

fgarcia commented Apr 22, 2018

Prerequisites

  • Checked that your issue hasn't already been filed by cross-referencing issues with the faq label
  • Checked next-gen ES issues and syntax problems by using the same environment and/or transpiler configuration without Mocha to ensure it isn't just a feature that actually isn't supported in the environment in question or a bug in your code.
  • 'Smoke tested' the code to be tested by running it outside the real test suite to get a better sense of whether the problem is in the code under test, your usage of Mocha, or Mocha itself
  • Ensured that there is no discrepancy between the locally and globally installed versions of Mocha. You can find them with: node node_modules/.bin/mocha --version(Local) and mocha --version(Global). We recommend avoiding the use of globally installed Mocha.

Description

Trying to fail a test with this.test.error() causes the test to be reported twice, as failed and as success

Steps to Reproduce

Run the test at:

https://github.com/mochajs/mocha/wiki/HOW-TO:-Conditionally-fail-a-test-after-completion

Expected behavior:

  something
    ✓ should one
    1) should two

  1 passing (16ms)
  1 failing

Actual behavior:

  something
    ✓ should one
    ✓ should two
    1) should two

  2 passing (11ms)
  1 failing

Additional information

There seems to be a fix in this rejected pull request
#1944

Related to issue #1635

@papb
Copy link

papb commented Nov 21, 2020

Hello! Can you please reopen this, since #3362 was reverted? I am still facing this issue.

@papb
Copy link

papb commented Nov 21, 2020

By the way, the same problem happens with beforeEach:

beforeEach(function() {
	try {
		assert.strictEqual(true, false);
	} catch (err) {
	 	this.test.error(err);
	}
});

it('foobar', function() {
	assert.strictEqual(true, true);
});

Output:

1) foobar           <-- red
√ foobar            <-- green

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug a defect, confirmed by a maintainer
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants