fix nested describe.only suites; closes #2406 #2411
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously, tests in nested
describe.only
suites would not be registered asonly
tests in their parent suite (due to the implementation described in #2387 (comment)). This caused mocha to think that the parent suite had noonly
tests, so the suite was skipped entirely. (See #2406 for more information.)This PR moves some of the logic for
it.only
anddescribe.only
to the test runner, rather than the place where suites are created. This makes the logic slightly simpler, because all of the suites already exist at the time thatonly
suites are handled.The correct logic for
only
blocks (from what I can tell, looking at the existing tests and the docs) is as follows:To run a suite:
only
suites/tests among all of its descendants, run all of its child suites and tests.only
tests among its children, run theonly
tests for that suite, and skip all the child suites.only
suites. Also run any child suites that haveonly
suites/tests as descendants.