Jest suppresses errors in describe callback when only running specific tests
See original GitHub issue🐛 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
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (2 by maintainers)

Top Related StackOverflow Question
jest-circuswill supersedejest-jasmine2as the default test framework implementation soon, so that will solve it for most people anyway. It might not be trivial to fix the suppression injest-jasmine2so possibly not worth it for something that’s obsolete soon. You can opt in tojest-circusnow if you want to try it out BTW 😃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.