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
{{ message }}
This repository was archived by the owner on Jan 26, 2019. It is now read-only.
Copy file name to clipboardExpand all lines: packages/react-scripts/template/README.md
+27-11
Original file line number
Diff line number
Diff line change
@@ -455,7 +455,7 @@ Now you are ready to use the imported React Bootstrap components within your com
455
455
456
456
Flow is a static type checker that helps you write code with fewer bugs. Check out this [introduction to using static types in JavaScript](https://medium.com/@preethikasireddy/why-use-static-types-in-javascript-part-1-8382da1e0adb) if you are new to this concept.
457
457
458
-
Recent versions of [Flow](http://flowtype.org/) work with Create React App projects out of the box.
458
+
Recent versions of [Flow](http://flowtype.org/) work with Create React App projects out of the box.
459
459
460
460
To add Flow to a Create React App project, follow these steps:
461
461
@@ -793,18 +793,34 @@ and then use them in your tests like you normally do.
793
793
794
794
>Note: this feature is available with `[email protected]` and higher.
795
795
796
-
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.
796
+
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.ts` to your project. It will be automatically executed before running your tests.
797
797
798
798
For example:
799
799
800
-
#### `src/setupTests.js`
800
+
#### `src/setupTests.ts`
801
801
```js
802
-
constlocalStorageMock= {
803
-
getItem:jest.fn(),
804
-
setItem:jest.fn(),
805
-
clear:jest.fn()
802
+
declare global {
803
+
interface localStorage {
804
+
getItem: any;
805
+
setItem: any;
806
+
clean: any;
807
+
}
808
+
}
809
+
810
+
classLocalStorageMock {
811
+
store = {};
812
+
clear() {
813
+
this.store= {};
814
+
}
815
+
getItem(key:any) {
816
+
returnthis.store[key];
817
+
}
818
+
setItem(key:any, value:any) {
819
+
this.store[key] =value.toString();
820
+
}
806
821
};
807
-
global.localStorage= localStorageMock
822
+
823
+
global.localStorage=newLocalStorageMock();
808
824
```
809
825
810
826
### Focusing and Excluding Tests
@@ -913,7 +929,7 @@ This feature is experimental and still [has major usage issues](https://github.c
913
929
914
930
### Editor Integration
915
931
916
-
If you use [Visual Studio Code](https://code.visualstudio.com), there is a [Jest extension](https://github.com/orta/vscode-jest) which works with Create React App out of the box. This provides a lot of IDE-like features while using a text editor: showing the status of a test run with potential fail messages inline, starting and stopping the watcher automatically, and offering one-click snapshot updates.
932
+
If you use [Visual Studio Code](https://code.visualstudio.com), there is a [Jest extension](https://github.com/orta/vscode-jest) which works with Create React App out of the box. This provides a lot of IDE-like features while using a text editor: showing the status of a test run with potential fail messages inline, starting and stopping the watcher automatically, and offering one-click snapshot updates.
917
933
918
934

919
935
@@ -1147,15 +1163,15 @@ GitHub Pages doesn't support routers that use the HTML5 `pushState` history API
1147
1163
### Heroku
1148
1164
1149
1165
Use the [Heroku Buildpack for Create React App](https://github.com/mars/create-react-app-buildpack).<br>
1150
-
You can find instructions in [Deploying React with Zero Configuration](https://blog.heroku.com/deploying-react-with-zero-configuration).
1166
+
You can find instructions in [Deploying React with Zero Configuration](https://blog.heroku.com/deploying-react-with-zero-configuration).
1151
1167
1152
1168
#### Resolving "Module not found: Error: Cannot resolve 'file' or 'directory'"
1153
1169
1154
1170
Sometimes `npm run build` works locally but fails during deploy via Heroku with an error like this:
1155
1171
1156
1172
```
1157
1173
remote: Failed to create a production build. Reason:
1158
-
remote: Module not found: Error: Cannot resolve 'file' or 'directory'
1174
+
remote: Module not found: Error: Cannot resolve 'file' or 'directory'
0 commit comments