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
@@ -674,6 +675,24 @@ import { expect } from 'chai';
674
675
675
676
and then use them in your tests like you normally do.
676
677
678
+
### Initializing Test Environment
679
+
680
+
>Note: this feature is available with `react-scripts@0.4.0` and higher.
681
+
682
+
If your app uses a browser API that you need to mock in your tests or if you just need a global setup before running your tests, add a `src/setupTests.js` to your project. It will be automatically executed before running your tests.
683
+
684
+
For example:
685
+
686
+
#### `src/setupTests.js`
687
+
```js
688
+
const localStorageMock = {
689
+
getItem: jest.fn(),
690
+
setItem: jest.fn(),
691
+
clear: jest.fn()
692
+
};
693
+
global.localStorage = localStorageMock
694
+
```
695
+
677
696
### Focusing and Excluding Tests
678
697
679
698
You can replace `it()` with `xit()` to temporarily exclude a test from being executed.
0 commit comments