jest: getVersion is not defined
🐛 Bug Report
Jest v24 crashes with “getVersion” is not defined.
To Reproduce
See source code.
Expected behavior
Jest does not crash.
Issue in source
This line requires cli
.
But cli
itself requires jest
here. Clearly, getVersion
is not exported at this point.
Run npx envinfo --preset jest
Paste the results here:
System:
OS: Windows 10
CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Binaries:
Yarn: 1.10.1 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.4.1 - C:\Program Files\nodejs\npm.CMD
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 10
- Comments: 37 (18 by maintainers)
Commits related to this issue
- fix: jest@24 getVersion undefined error https://github.com/facebook/jest/issues/7704 — committed to bencode/react-test-mate by bencode 5 years ago
- refactor(test): remove workaround for jest 24 The workaround was needed because jest 24.0 had a dependency cycle and therefore was problematic to import and use programatically. See https://github.co... — committed to freecloudio/web by riesinger 5 years ago
- refactor(workflow-plugin-react): workaround for jest get version removed https://github.com/facebook/jest/issues/7704 was resolved in a new version of jest — committed to Availity/availity-workflow by GoPro16 5 years ago
- refactor(workflow-plugin-angular): workaround for jest get version removed https://github.com/facebook/jest/issues/7704 was resolved in a new version of jest — committed to Availity/availity-workflow by GoPro16 5 years ago
@eliw00d @hediet workaround before new release:
24.1.0 is released
I’m running into this same error but only when running jest programmatically (
require('jest').run(argv)
). When Iyarn jest
it works fine.I kinda don’t wanna rush anyone, but maybe it’s time to let it go with version
24.0.1
🛸#7707 fixes this issue. #7696 will probably land soonish, proper programmatic API… I don’t know. Maybe 25? 🙂 I’ll open up an issue for it requesting feedback
Battlefield news: 📰
I have managed to start Jest by adding those lines into the
scripts/test.js
:After, when I’m start Jest to run all over the tests, it shows this:
Unable to locate any of the test files. 🔍
The fix #7707 is not yet released.
Ah, ok. We need #7696 😅
I’ll put together a PR
Thank you, we also run it programmatically. That seems to be it.
Not sure what’s happening, but one thing that’s bitten me before is mismatching
jest
installations.Make sure to not have both
jest
andjest-cli
installed at the same time (you just needjest
), and that you’re not using CRA (CRA ships with its own version of Jest, so you shouldn’t update it yourself 🙂)I can’t repro the error. Can you share what you executed when it crashed?