question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
natealcedocommented, Aug 31, 2018

@SimenB I’d love to send in a PR. Will do when I get the chance to do so!

0reactions
github-actions[bot]commented, May 12, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found