You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
>Note: To use a different preprocessor, replace `build-css` and `watch-css` commands according to your preprocessor’s documentation.
@@ -672,7 +672,7 @@ Then we can change `start` and `build` scripts to include the CSS preprocessor c
672
672
+ "start": "npm-run-all -p watch-css start-js",
673
673
+ "build-js": "react-scripts build",
674
674
+ "build": "npm-run-all build-css build-js",
675
-
"test": "react-scripts test --env=jsdom",
675
+
"test": "react-scripts test",
676
676
"eject": "react-scripts eject"
677
677
}
678
678
```
@@ -1676,23 +1676,14 @@ The build command will check for linter warnings and fail if any are found.
1676
1676
1677
1677
### Disabling jsdom
1678
1678
1679
-
By default, the `package.json` of the generated project looks like this:
1680
-
1681
-
```js
1682
-
"scripts": {
1683
-
"start":"react-scripts start",
1684
-
"build":"react-scripts build",
1685
-
"test":"react-scripts test --env=jsdom"
1686
-
```
1687
-
1688
-
If you know that none of your tests depend on [jsdom](https://github.com/tmpvar/jsdom), you can safely remove `--env=jsdom`, and your tests will run faster:
1679
+
If you know that none of your tests depend on [jsdom](https://github.com/tmpvar/jsdom), you can safely set `--env=node`, and your tests will run faster:
1689
1680
1690
1681
```diff
1691
1682
"scripts": {
1692
1683
"start": "react-scripts start",
1693
1684
"build": "react-scripts build",
1694
-
-"test":"react-scripts test --env=jsdom"
1695
-
+"test":"react-scripts test"
1685
+
- "test": "react-scripts test"
1686
+
+ "test": "react-scripts test --env=node"
1696
1687
```
1697
1688
1698
1689
To help you make up your mind, here is a list of APIs that **need jsdom**:
@@ -1730,7 +1721,7 @@ There are various ways to setup a debugger for your Jest tests. We cover debuggi
1730
1721
Add the following to the `scripts` section in your project's `package.json`
1731
1722
```json
1732
1723
"scripts": {
1733
-
"test:debug":"react-scripts --inspect-brk test --runInBand --env=jsdom"
1724
+
"test:debug": "react-scripts --inspect-brk test --runInBand"
1734
1725
}
1735
1726
```
1736
1727
Place `debugger;` statements in any test and run:
@@ -1766,8 +1757,7 @@ Use the following [`launch.json`](https://code.visualstudio.com/docs/editor/debu
1766
1757
"args": [
1767
1758
"test",
1768
1759
"--runInBand",
1769
-
"--no-cache",
1770
-
"--env=jsdom"
1760
+
"--no-cache"
1771
1761
],
1772
1762
"cwd": "${workspaceRoot}",
1773
1763
"protocol": "inspector",
@@ -2004,7 +1994,7 @@ Then in `package.json`, add the following line to `scripts`:
Then to analyze the bundle run the production build then run the analyze
@@ -2493,7 +2483,7 @@ If none of these solutions help please leave a comment [in this thread](https://
2493
2483
2494
2484
### `npm test` hangs or crashes on macOS Sierra
2495
2485
2496
-
If you run `npm test` and the console gets stuck after printing `react-scripts test --env=jsdom` to the console there might be a problem with your [Watchman](https://facebook.github.io/watchman/) installation as described in [facebook/create-react-app#713](https://github.com/facebook/create-react-app/issues/713).
2486
+
If you run `npm test` and the console gets stuck after printing `react-scripts test` to the console there might be a problem with your [Watchman](https://facebook.github.io/watchman/) installation as described in [facebook/create-react-app#713](https://github.com/facebook/create-react-app/issues/713).
2497
2487
2498
2488
We recommend deleting `node_modules`in your project and running `npm install` (or `yarn`if you use it) first. If it doesn't help, you can try one of the numerous workarounds mentioned in these issues:
0 commit comments