-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Description
🐛 Bug Report
If you run a specific test (such as using --testNamePattern - there could be other ways, but this is how I found the bug), jest will eat any errors thrown outside of that test, skipping the test and sometimes complaining about a describe callback not returning a value.
I did do a very minor dive into this a while ago, before I determined the cause (as when I first started jest I was getting these strange "a describe callback must not return a value", despite never returning a value) - somewhere internally something returns null instead of undefined, which jest doesn't know it's doing and hence complains to the developer.
To Reproduce
- Write a test file that errors outside of an
test/itblock, that is inside at least onedescribeblock - Run the test specifically using a parameter like
--testNamePatten
Expected behavior
Jest tells me that the error happened, in the same manner it does when I run the describe block.
Jest also shouldn't complain about a describe callback shouldn't have a return value (which it does even if I'm running the describe block - let me know if you'd like me to make a separate issue for this)
Link to repl or repo (highly encouraged)
Here is an example repo.
Do npm run showcase to see the bug in action.
Heres what it outputs on my side:
PS C:\Users\G-Rath\workspace\projects-personal\js-bugs> jest "--testNamePattern=^test$" --runTestsByPath test/test.spec.js
console.log node_modules/jest-jasmine2/build/jasmine/Env.js:520
● Test suite failed to run
A "describe" callback must not return a value.
Returning a value from "describe" will fail the test in a future version of Jest.
> 1 | describe('test', () => {
| ^
2 | throw new Error();
3 |
4 | it('showcases the bug', () => {
at addSpecsToSuite (node_modules/jest-jasmine2/build/jasmine/Env.js:522:17)
at Object.<anonymous> (test/test.spec.js:1:24)
Test Suites: 1 skipped, 0 of 1 total
Tests: 1 skipped, 1 total
Snapshots: 0 total
Time: 2.03s
Ran all test suites within paths "test/test.spec.js".
Run npx envinfo --preset jest
Paste the results here:
System:
OS: Windows 10
CPU: (8) x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
Binaries:
Node: 10.15.3 - C:\nodejs\node.EXE
Yarn: 1.13.0 - ~\AppData\Roaming\npm\yarn.CMD
npm: 6.9.0 - ~\AppData\Roaming\npm\npm.CMD