SyntaxError: Identifier 'jest' has already been declared
See original GitHub issueIf you are reporting a bug, please fill in below. Otherwise feel free to remove this template entirely.
Can you reproduce the problem with latest npm?
Yes after updating to the latest version the issue still occurs
###Can you still reproduce it?
Yes issue still occurs
Description
An issue with running test using jest v18.0.0
Expected behavior
The declared variable within the test.js
file would be the first instance, or the jest global variable to be available within the test.js
Actual behavior
Error is logged, stating that jest
has already been declared
Environment
Run these commands in the project folder and fill in their results:
npm ls react-scripts
(if you haven’t ejected):node -v7.3.0
:npm -3.10.10
:
Then, specify:
- Operating system: macOs Sierra
- Browser and version: Chrome Version 55.0.2883.95 (64-bit)
Reproducible Demo
To re-create the issue;
- run
create-react-app
npm run eject
- update jest version to
18.0.0
npm run test
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
[@jest/globals] Identifier 'jest' has already been declared #9920
The FE part, ES modules transpiled with babel, seems to be just fine. The BE part is probably not expecting to import/require jest...
Read more >jestjs - "Identifier 'global' has already been declared at ...
I upgraded my react project to use monaco-editor version 0.21.0, since then the jest tests for files ...
Read more >Identifier has already been declared Error in JavaScript
The "Identifier has already been declared error" occurs when a variable with the same name has been declared multiple times in the same...
Read more >Identifier 'jest' has already been declared in file 'dist\__tests__ ...
Fixing error: SyntaxError: Identifier 'jest' has already been declared in file 'dist\__tests__\import-editions-test.js'.
Read more >Solved: JavaScript switch/case "Identifier '...' has already been ...
Fix for "Identifier '...' has already been declared" when using JavaScript switch/case ... If you specify the same variable name (created using ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@gaearon jest@18 tries to run the file scripts/test.js as a test. It is configured to look for test files in src/, which it now also matches to scr/* making it look in the scripts folder.
See #1311