Error trace cryptic when a method reference not passed to afterEach
See original GitHub issue🐛 Bug Report
The error trace generated when a method reference is not passed as expected to afterEach is cryptic and hard to debug.
To Reproduce
import React from 'react';
import {cleanup} from 'react-testing-library';
import 'jest-dom/extend-expect';
afterEach(cleanup());
test("Hello World", () => {});
// several other tests but they they are not relevant to this example and have been excluded to keep the question simple
Expected behavior
An appropriate error message that suggests that the problem is in the afterEach
line so that as a developer I can know what went wrong and fix it, without manually guessing which of my 100 lines of test code is problematic.
Link to repl or repo (highly encouraged)
https://repl.it/@anuragkapur/ProudDependablePhysics
Run npx envinfo --preset jest
Paste the results here:
System:
OS: macOS High Sierra 10.13.6
CPU: x64 Intel(R) Core(TM) i7-6660U CPU @ 2.40GHz
Binaries:
Node: 8.2.0 - /usr/local/bin/node
npm: 5.3.0 - /usr/local/bin/npm
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:11 (5 by maintainers)
Top Results From Across the Web
Jest - afterEach() - method call with and without parenthesis
In terms of why the error is so cryptic, it is likely that the internals of Jest are expecting a function reference to...
Read more >Troubleshooting Your Solution | The Codewars Docs
This guide covers common problems you may run into as a newcomer solving kata on Codewars, outlining common mistakes and their typical solutions....
Read more >Method References in Java | Baeldung
A quick and practical overview of method references in Java. ... a method reference to have the compiler handle parameter passing for us:...
Read more >On Compiler Error Messages: What They Say and ... - Hindawi
Programmers often encounter cryptic compiler error messages that are difficult to understand and thus difficult to resolve.
Read more >Writing R Extensions - The Comprehensive R Archive Network
This field is what is reported by the maintainer function and used by bug.report . For a CRAN package it should be a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@SimenB I’d love to send in a PR. Will do when I get the chance to do so!
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.