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

TypeError: require(...) is not a function after upgrade #5628

Closed
jasperblues opened this issue Feb 21, 2018 · 10 comments
Closed

TypeError: require(...) is not a function after upgrade #5628

jasperblues opened this issue Feb 21, 2018 · 10 comments

Comments

@jasperblues
Copy link

Do you want to request a feature or report a bug?

Potential bug.

What is the current behavior?

Jest @21.2.1, I am able to execute tests without issues.
Jest @latest, results in:

TypeError: require(...) is not a function
    at /Users/jblues/vampr/vend_node/node_modules/jest/node_modules/jest-cli/build/run_jest.js:205:46
    at Generator.next (<anonymous>)
    at step (/Users/jblues/vampr/vend_node/node_modules/jest/node_modules/jest-cli/build/run_jest.js:27:377)
    at /Users/jblues/vampr/vend_node/node_modules/jest/node_modules/jest-cli/build/run_jest.js:27:537
    at <anonymous>

If the current behavior is a bug, please provide the steps to reproduce and
either a repl.it demo through https://repl.it/languages/jest or a minimal
repository on GitHub that we can yarn install and yarn test.

Haven't stripped it down to something that I can share publicly yet.

What is the expected behavior?

Please provide your exact Jest configuration and mention your Jest, node,
yarn/npm version and operating system.

Able to execute tests on latest jest.

@thymikee
Copy link
Collaborator

It's probably related to your package manager. Please purge node_modules and try again. Also, we can't action this without a repro.

@jasperblues
Copy link
Author

purge of node_modules didn't work. updating from node 8.9.1 to 9.5.0 didn't work either.

appreciate that you can't take action without a repro - will see what i can prepare. in the meantime I wanted to put it on your radar in case it is something that others are experiencing.

thanks.

@jasperblues
Copy link
Author

jasperblues commented Feb 21, 2018

Repro Steps:

Add: globalSetup: "./test/jest.global.setup.js", to jest.config.js

jest.global.setup.js:

console.log('hello from global setup'); 

Removing global setup works. Issue didn't occur on older jet, because global setup is not supported in jest 21.2.1 (which wasn't clear to me from the docs - this is only evident at runtime).

@thymikee
Copy link
Collaborator

I'm sorry, but this is not a sufficient repro. We need a repo we can check out to

@jasperblues
Copy link
Author

Yes, I'll get to that eventually. Keeping you updated. Please keep this issue closed and I'll open a new one when I have a public repository that reproduces the issue.

Happy to help out! Take care.

@thymikee
Copy link
Collaborator

Cool, looking forward to it, and thanks for taking care to make a repro!

@rjhilgefort
Copy link

I'm seeing this same issue doing a very similar thing to @jasperblues. My tests run as expected until I add a globalSetup file.

@thymikee I was able to reproduce on a clean/new repo as you requested.

https://github.com/rjhilgefort/facebook-jest-5628

image

@SimenB
Copy link
Member

SimenB commented Mar 19, 2018

globalSetup needs to export a function. Why the error handling in this case is so bad, I'm not sure...

EDIT: Oh, since it tries to invoke it :P PR incoming This is a good first issue, actually, so I'll leave it.

The error is here: https://github.com/facebook/jest/blob/124067e7d662364d40fc662ef54bfddd798c57c4/packages/jest-cli/src/run_jest.js#L203-L206

It should do the require first, then do a typeof globalSetup === 'function' and throw a descriptive error otherwise.

Should do the same here: https://github.com/facebook/jest/blob/124067e7d662364d40fc662ef54bfddd798c57c4/packages/jest-cli/src/run_jest.js#L217-L220

@SimenB
Copy link
Member

SimenB commented Mar 21, 2018

#5835

@SimenB SimenB closed this as completed Mar 21, 2018
@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

No branches or pull requests

4 participants