Example:
https://repl.it/repls/CavernousElegantIvorybilledwoodpecker
When test cases get long, it's possible to mistakenly write a test case inside of another test case. Sometimes humans get mixed up on parentheses and braces.
When this happens, the internal test() method does not execute, and no errors are shown. Thus it's easy to add a test case that never runs.
I can't think of a reason to nest test cases, so my feeling is the expected behavior would be to raise an error in this situation.
Can you try this with Jest 22? We changed this to throw! Happy to reopen if it鈥檚 not fixed.
In #4039, for reference.
We should probably have a test for that behavior...
@cpojer It works _exactly_ as I would like under Jest 22! Excellent error messages! Thank you!
Tests cannot be nested. Test
adds 2 + 3 to equal 6cannot run because it is nested withinadds 1 + 2 to equal 3.
I came across this issue when trying to write nested data driven tests .. e.g. for each browser.. for each site .. but got error "Tests cannot be nested."
Is disallowing nested tests by design? Can you explain why please. @SimenB
Use describe for nesting and test.each for multiple cases
Thanks a lot @thymikee
Didn't know about describe.each()
Most helpful comment
Use describe for nesting and test.each for multiple cases