🚀 Feature: Throw on nested it call #4525
Labels
semver-major
implementation requires increase of "major" version number; "breaking changes"
status: accepting prs
Mocha can use your help with this one!
type: feature
enhancement proposal
Is your feature request related to a problem or a nice-to-have?? Please describe.
It would be nice for Mocha to throw if it founds a nested
it
block. Currently, such blocks are silently ignored (code inside nested block is not called), but developers mistakenly can assume that they are called and test something.I'm talking about such code:
In such a simple example it's easy to spot the error but if you have a complex test structure, it's easy to accidentally create such a structure. And you would think that tests really test your code unless you add logs in nested it block and find out that none of your tests are really called.
Example of a more complex test structure:
Describe the solution you'd like
Throw an error if find nested it block
Describe alternatives you've considered
You could also call nested it blocks, but it would create a strange test structure and it would not be consistent with other test libraries (e.g. jest)
Additional context
In jest such feature was implemented in jestjs/jest#9828
repo to check out with mocha and jest: https://github.com/DimaDK02/mocha-opportunity-to-improve/
Run
yarn jest
to run jest on this test andyarn mocha
to run mochaThe text was updated successfully, but these errors were encountered: