@@ -177,6 +177,10 @@ Jest `moduleDirectories` option.
177177This will make all the ` .js ` files in the test-utils directory importable
178178without ` ../ ` .
179179
180+ > ** Note**
181+ >
182+ > This can't be used with Create React App.
183+
180184``` diff title="my-component.test.js"
181185- import { render, fireEvent } from '../test-utils';
182186+ import { render, fireEvent } from 'test-utils';
@@ -194,45 +198,20 @@ module.exports = {
194198}
195199```
196200
197- _ Typescript config needs to be updated as follow:_
201+ If you're using TypeScript, merge this into your ` tsconfig.json ` . If you're
202+ using Create React App without TypeScript, save this to ` jsconfig.json ` instead.
198203
199204``` diff title="tsconfig.json"
200205{
201206 "compilerOptions": {
202- // ...,
203- + "baseUrl": "src",
204- + "paths": {
205- + "test-utils": ["./utils/test-utils"]
206- + }
207+ "baseUrl": "src",
208+ "paths": {
209+ "test-utils": ["./utils/test-utils"]
210+ }
207211 }
208212}
209213```
210214
211- ### Jest and Create React App
212-
213- If your project is based on top of Create React App, to make the ` test-utils `
214- file accessible without using relative imports, you just need to create a ` .env `
215- file in the root of your project with the following configuration:
216-
217- ```
218- // Create React App project structure
219-
220- $ app
221- .
222- ├── .env
223- ├── src
224- │ ├── utils
225- │ │ └── test-utils.js
226- │
227- ```
228-
229- ```
230- // .env
231-
232- // example if your utils folder is inside the /src directory.
233- NODE_PATH=src/utils
234- ```
235-
236215### Jest 24 (or lower) and defaults
237216
238217If you're using the Jest testing framework version 24 or lower with the default
0 commit comments