Empty describe block throws error
See original GitHub issue🐛 Bug Report
If a describe
block is left empty, with no tests passed to it, an error is thrown because the list of tests is not defined. Whether this is valid or not, it should probably return a specific message instead of a cryptic runtime error.
If I have an empty describe
like:
describe('Scenario needing some tests')
It will fail with Cannot read property 'length' of undefined
:
● Test suite failed to run
TypeError: Cannot read property 'length' of undefined
at Env.describe (node_modules/jest-jasmine2/build/jasmine/Env.js:297:27)
at Object.<anonymous> (client/test/components/AccountChooser/AccountChooser-test.js:10:1)
at Generator.next (<anonymous>)
at new Promise (<anonymous>)
at Generator.next (<anonymous>)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
Personally I find the workflow of creating a describe
block for every set of tests I know I will need up front, and then coming back and filling them in as I get time, to be really useful. Some may argue that it should be considered invalid, but in that case it should throw an error explaining as much.
To Reproduce
Just create a describe
instance with only a name param supplied
Expected behavior
Either no error at all, or a friendly error message like ‘Every describe block requires some tests’
Link to repl or repo (highly encouraged)
https://repl.it/repls/UnselfishAmusedNanocad
Run npx envinfo --preset jest
Paste the results here:
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (2 by maintainers)
Top GitHub Comments
This is basically #5558, but for
describe
instead ofit
/test
. Wanna send a PR for it?This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.