Commit 5a0b1ef5 authored by Danny Calleri's avatar Danny Calleri Committed by Dan Abramov
Browse files

Better documentation for setupTests.js when ejecting (#3656)

* Better documentation for setupTests.js when ejecting

When running `npm run eject` before creating `src/setupTests.js`, the resulting `package.json` file, won't contain any entry for it - and this is correct in my opinion, since otherwise Jest will crash - but it's useful to have it documented and avoid pointless waste of time.

* Added additional note about src/setupTests.js

Added another note about src/setupTests.js and `npm run eject` in Testing Components section

* Update README.md

* Update README.md
parent 344ddfa3
3 merge requests!12191Lim.Pisey.168:/Identified - We are currently investigating reports of missing build logs. The issue has been identified and a resolution is in progress. We will provide a further update when available.Mar 21, 09:02 UTC,!12853brikk,!5717Automatically extract project file structure from build bundle file
Showing with 9 additions and 2 deletions
+9 -2
...@@ -1334,7 +1334,7 @@ import Adapter from 'enzyme-adapter-react-16'; ...@@ -1334,7 +1334,7 @@ import Adapter from 'enzyme-adapter-react-16';
configure({ adapter: new Adapter() }); configure({ adapter: new Adapter() });
``` ```
(Note that **if you already ejected** before creating `src/setupTests.js`, this won’t work unless you set [this Jest option](https://facebook.github.io/jest/docs/en/configuration.html#setuptestframeworkscriptfile-string) to point to `src/setupTests.js`.) >Note: Keep in mind that if you decide to "eject" before creating `src/setupTests.js`, the resulting `package.json` file won't contain any reference to it. [Read here](#initializing-test-environment) to learn how to add this after ejecting.
Now you can write a smoke test with it: Now you can write a smoke test with it:
...@@ -1425,7 +1425,14 @@ const localStorageMock = { ...@@ -1425,7 +1425,14 @@ const localStorageMock = {
global.localStorage = localStorageMock global.localStorage = localStorageMock
``` ```
Note that **if you already ejected** before creating `src/setupTests.js`, this won’t work unless you set [this Jest option](https://facebook.github.io/jest/docs/en/configuration.html#setuptestframeworkscriptfile-string) to point to `src/setupTests.js`. >Note: Keep in mind that if you decide to "eject" before creating `src/setupTests.js`, the resulting `package.json` file won't contain any reference to it, so you should manually create the property `setupTestFrameworkScriptFile` in the configuration for Jest, something like the following:
>```js
>"jest": {
> // ...
> "setupTestFrameworkScriptFile": "<rootDir>/src/setupTests.js"
> }
> ```
### Focusing and Excluding Tests ### Focusing and Excluding Tests
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment