Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SyntaxError: Identifier 'jest' has already been declared

See original GitHub issue

If 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


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 Screen Shot 2016-12-24 at 20.47.24.png


Run these commands in the project folder and fill in their results:

  1. npm ls react-scripts (if you haven’t ejected):
  2. node -v7.3.0:
  3. npm -3.10.10:

Then, specify:

  1. Operating system: macOs Sierra
  2. 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:closed
  • Created 7 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

bondzcommented, Dec 24, 2016

@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.

bondzcommented, Dec 24, 2016

See #1311

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found