Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
a1300 opened this issue Aug 28, 2018 · 5 comments · Fixed by #6917
Closed

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

a1300 opened this issue Aug 28, 2018 · 5 comments · Fixed by #6917

Comments

@a1300
Copy link

a1300 commented Aug 28, 2018

🐛 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
@SimenB
Copy link
Member

SimenB commented 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

@ranyitz
Copy link
Contributor

ranyitz commented Aug 29, 2018

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

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

@mohit2872
Copy link

Can you assign me this issue?

SimenB pushed a commit that referenced this issue Aug 30, 2018
@SimenB
Copy link
Member

SimenB commented Aug 30, 2018

@mohit2872 we already had an open PR when you commented, sorry!

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants