-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
semver-majorimplementation requires increase of "major" version number; "breaking changes"implementation requires increase of "major" version number; "breaking changes"status: accepting prsMocha can use your help with this one!Mocha can use your help with this one!type: buga defect, confirmed by a maintainera defect, confirmed by a maintainer
Milestone
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_modules/.bin/mocha --version(Local) andmocha --version(Global). We recommend that you not install Mocha globally.
Description
Where they are multiple .only in a test, with one of them in a context, while the second one is not, only the one in a context will be run.
describe('#addition', function () {
context('When a and b are number', function () {
it.only('should return the addition', async function () {
// will be run
});
});
it.only('should throw an error', async function () {
// will not be run
});
});Steps to Reproduce
- Clone the MVCE repo here :
git clone https://github.com/1024pix/mocha-context-only-bug - Install dependencies
npm install - Run tests :
./node_modules/mocha/bin/mocha test.js
Expected behavior:
The two tests should be run.
Actual behavior:
Only the test in context is run, the second seems to be ignored.
Reproduces how often:
100%
Versions
- The output of
mocha --versionandnode_modules/.bin/mocha --version: 9.2.1 - The output of
node --version: v14.17.0 - Your operating system
- name and version: macOS 12.2.1
- architecture (32 or 64-bit): 64bit
- Your shell (e.g., bash, zsh, PowerShell, cmd): zsh
- Your browser and version (if running browser tests): n/a
- Any third-party Mocha-related modules (and their versions): no
- Any code transpiler (e.g., TypeScript, CoffeeScript, Babel) being used (and its version): no
Additional Information
n/a
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
semver-majorimplementation requires increase of "major" version number; "breaking changes"implementation requires increase of "major" version number; "breaking changes"status: accepting prsMocha can use your help with this one!Mocha can use your help with this one!type: buga defect, confirmed by a maintainera defect, confirmed by a maintainer
Type
Projects
Status
No status