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)
beforeEach('setup delegate.js', () => {
});
A better error message, that points to the problem:
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
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
Thanks @a1300 for reporting the issue and @SimenB for guidance.
I've created a PR with a fix - #6917
Can you assign me this issue?
@mohit2872 we already had an open PR when you commented, sorry!
Most helpful comment
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