Open
Description
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) andmocha --version
(Global). We recommend that you not install Mocha globally.
Description
Steps to Reproduce
-
mkdir temp && cd temp && npm init -y && npm i -D mocha
-
Create
test/test.js
:
const assert = require('assert');
describe('First test block', function() {
after(function() {
// I know this code doesn't make sense in real life, it's just to show the issue
this.test.error(new Error());
});
it('First test', function() {
assert.strictEqual(true, true);
});
});
describe('Second test block', function() {
it('Second test', function() {
assert.strictEqual(true, true);
});
});
- Run
npx mocha test/*.js && echo 'ok'
Expected behavior: Mocha should exit with nonzero exit code and tell me that something is wrong.
Actual behavior:
First test block
√ First test
ok
Mocha completely swallowed the error and exited with exit code 0. Some tests didn't even run!
Reproduces how often: Every time
Versions
- The output of
npx mocha --version
: 8.2.1 - The output of
node --version
: v12.14.1
Activity