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.

Naming the beforeEach function produces imprecise error: fn.call is not a function

See original GitHub issue

🐛 Bug Report

After migrating from mocha to jest. I got the following error for naming the beforeEach function:

TypeError: fn.call is not a function
at resolve (node_modules/jest-jasmine2/build/queue_runner.js:56:12)

To Reproduce

beforeEach('setup delegate.js', () => {
});

Expected behavior

A better error message, that points to the problem:

Link to repl

Link to reproduction.

Result:

Jest v22.1.2 node v7.4.0 linux/amd64
   
 FAIL  ./add-test.js
  add
    ✕ should add two numbers (7ms)

  ● add › should add two numbers

    TypeError: fn.call is not a function
      
      at resolve (../../usr/local/share/.config/yarn/global/node_modules/jest-jasmine2/build/queue_runner.js:52:12)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        0.981s
Ran all test suites.
exit status 1

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
SimenBcommented, Aug 29, 2018

I’ll copy parts of my comment from #4613 for others to more easily contribute.


Wanna send a PR giving a better error?

For Jest Circus the code is here: https://github.com/facebook/jest/blob/c93e02718480b9f25b0d28f33456ed159bd11b69/packages/jest-circus/src/index.js#L42-L48 For Jest Jasmine it’s here: https://github.com/facebook/jest/blob/c93e02718480b9f25b0d28f33456ed159bd11b69/packages/jest-jasmine2/src/jasmine/Env.js#L505-L539

It’s a matter of type-checking that the first argument is indeed a function

1reaction
ranyitzcommented, Aug 29, 2018

Thanks @a1300 for reporting the issue and @SimenB for guidance.

I’ve created a PR with a fix - #6917

Read more comments on GitHub >

github_iconTop Results From Across the Web

Vue: beforeEach is not a function - Stack Overflow
You've capitalized Router , that's the class name. What you want to do is add your .beforeEach() to the instance of the router....
Read more >
HP 33s scientific calculator user's manual
File name 33s-English-Manual-040130-Publication(Edition 2).doc Page : 388 ... Pressing the function key produces the ... Integrating Equations ( ∫ FN).
Read more >
PM0264 STM32 Cortex®-M33 MCUs programming manual
This programming manual provides information for application and system-level software developers. It gives a full description.
Read more >
Report - Investigation of the Challenger Accident - GovInfo
fective functioning of NASA's Space Shuttle program, it should be ... Rogers Commission that this tragic accident was not caused by the.
Read more >
zshoptions(1) — zsh-common — Debian testing
It is possible for options to be set within a function scope. ... this will not work with MENU_COMPLETE, since repeated completion calls...
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