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 Nov 16, 2023. It is now read-only.
Notice we installed packages `enzyme` as well as `@types/enzyme`.
261
261
The `enzyme` package refers to the package containing JavaScript code that actually gets run, while `@types/enzyme` is a package that contains declaration files (`.d.ts` files) so that TypeScript can understand how you can use Enzyme.
262
262
You can learn more about `@types` packages [here](https://www.typescriptlang.org/docs/handbook/declaration-files/consumption.html).
263
263
264
-
We also had to install `react-addons-test-utils`.
264
+
We also had to install `enzyme-adapter-react-16 and react-test-renderer`.
265
265
This is something `enzyme` expects to be installed.
266
266
267
+
Before writing the first test, we have to configure Enzyme to use an adapter for React 16.
268
+
We'll create a file called `src/setupTests.ts` that is automatically loaded when running tests:
269
+
270
+
```ts
271
+
import*asenzymefrom'enzyme';
272
+
import*asAdapterfrom'enzyme-adapter-react-16';
273
+
274
+
enzyme.configure({ adapter: newAdapter() });
275
+
```
276
+
267
277
Now that we've got Enzyme set up, let's start writing our test!
268
278
Let's create a file named `src/components/Hello.test.tsx`, adjacent to our `Hello.tsx` file from earlier.
0 commit comments