Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty describe block throws error #6224

Closed
eddiesholl opened this issue May 22, 2018 · 9 comments
Closed

Empty describe block throws error #6224

eddiesholl opened this issue May 22, 2018 · 9 comments

Comments

@eddiesholl
Copy link
Contributor

eddiesholl commented May 22, 2018

🐛 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:

@eddiesholl
Copy link
Contributor Author

I originally filed this over at jest-community/vscode-jest#298 but it looks to be a generic jest issue

@SimenB
Copy link
Member

SimenB commented May 22, 2018

This is basically #5558, but for describe instead of it/test. Wanna send a PR for it?

@eddiesholl
Copy link
Contributor Author

Yep I'll give it a crack

@thymikee
Copy link
Collaborator

Awesome, looking forward to it :)

@mustafa-nimir
Copy link

hi, i would like to jump in into this issue
which behavior is better ? return no error and bypass or throw 'Every describe block requires some tests' ?

@mustafa-nimir
Copy link

@eddiesholl sorry i didn't notice that you have already started working on it .. its my first contribution to this project

@Brantron
Copy link

looks like this can be closed based on #6372

@SimenB
Copy link
Member

SimenB commented Oct 15, 2018

Right, thanks!

@SimenB SimenB closed this as completed Oct 15, 2018
@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants