-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Description
Prerequisites
- Checked that your issue hasn't already been filed by cross-referencing issues with the
faqlabel - 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 avoiding the use of globally installed Mocha.
Description
When using the --bail flag, mocha will exit with a status of 0, instead of 1, when it encounters an error in before hooks. This potentially causes CI to pass when it should fail.
Steps to Reproduce
let describe = require('mocha').describe;
let before = require('mocha').before;
describe('before-all-working', function() {
before(function() {
console.log('before hook');
throw new Error('before hook error');
});
it('test', function() {});
});xps:../backend-issue-965$ ./node_modules/.bin/mocha
before-all-working
before hook
1) "before all" hook
0 passing (4ms)
1 failing
1) before-all-working
"before all" hook:
Error: before hook error
at Context.<anonymous> (test:7:11)
xps:../backend-issue-965$ echo $?
1
xps:../backend-issue-965$ ./node_modules/.bin/mocha --bail
before-all-working
before hook
0 passing (3ms)
1) "before all" hook
xps:../backend-issue-965$ echo $?
0
Expected behavior: mocha exits with status 1
Actual behavior: mocha exits with status 0
Reproduces how often: 100%
Versions
- The output of
mocha --versionandnode node_modules/.bin/mocha --version: not globally installed /5.1.1 - The output of
node --version:8.11.1 - The version and architecture of your operating system:
Ubuntu 16.04.4 LTS x64 - Your shell (bash, zsh, PowerShell, cmd, etc.):
bash - Your browser and version (if running browser tests): N/A
- Any other third party Mocha related modules (with versions): N/A
- The code transpiler being used: N/A
Additional Information
None
Metadata
Metadata
Assignees
Labels
No labels