question-mark
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.

Documentation: missing instructions if setupTests.js is added after an eject

See original GitHub issue

initializing-test-environment doesn’t explain that "setupTestFrameworkScriptFile": "<rootDir>/src/setupTests.js", needs to be added to package.json if src/setupTests.js is created after the app has been “ejected” as createJestConfig only adds this configuration if the file is present (makes sense).

Standard template being:

{
  …
  "jest": {
    "setupFiles": [
      …
    ],
    "setupTestFrameworkScriptFile": "<rootDir>/src/setupTests.js",

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:5
  • Comments:16 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
dreadrockseancommented, Sep 4, 2018

I have the same problem as Doug. src/setupTests.js and it doesn’t work. Yet if I place the code in the test files themselves, it works.

2reactions
gaearoncommented, Jan 8, 2018

Documented in https://github.com/facebookincubator/create-react-app/commit/1c8a7f3fecc60cd1516ed3a28f274945de90b3db.

@dougbacelar Unfortunately we can’t help without a reproducing project.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use jest.config.js with create-react-app - Stack Overflow
For me appending -- --config=jest.config.js worked. So the whole string react-scripts test -- --config jest.config.js in your case.
Read more >
How To Set Up a React Project with Create React App
Starting a new JavaScript project with React used to be a complicated process. But now, Create React App includes all the JavaScript ......
Read more >
create-react-app - Breword 文档集合
#1721 Fix hot reloading for WebpackDevServer after eject. (@gaearon) ... #1222 Disable gh-page setup instruction if scripts.deploy has been added. (@n3tr).
Read more >
Don't eject your Create React App | by Adam Laycock - Medium
If you found yourself on this page because you want to eject your ... is missing a feature that I need, so I'm...
Read more >
learning / learning-dashboard · GitLab
Changing the HTML; Adding Assets Outside of the Module System; When to Use the public ... Read instructions below for using assets from...
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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found