Skip to content

Commit

Permalink
feat: Move @testing-library/dom and @types/react-dom to peer depe…
Browse files Browse the repository at this point in the history
…ndencies (#1305)

BREAKING CHANGE: `@testing-library/dom` was moved to a peer dependency and needs to be explicitly installed. This reduces the chance of having conflicting versions of `@testing-library/dom` installed that frequently caused bugs when used with `@testing-library/user-event`. We will also be able to allow new versions of `@testing-library/dom` being used without a SemVer major release of `@testing-library/react` by just widening the peer dependency.
`@types/react-dom` needs to be installed if you're typechecking files using `@testing-library/react`.

Co-authored-by: Matan Borenkraout <[email protected]>
  • Loading branch information
eps1lon and MatanBobi committed Jun 3, 2024
1 parent c1f2957 commit a4744fa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,24 @@ primary guiding principle is:
## Installation

This module is distributed via [npm][npm] which is bundled with [node][node] and
should be installed as one of your project's `devDependencies`:
should be installed as one of your project's `devDependencies`.
Starting from RTL version 16, you'll also need to install
`@testing-library/dom`:

```
npm install --save-dev @testing-library/react
npm install --save-dev @testing-library/react @testing-library/dom
```

or

for installation via [yarn][yarn]

```
yarn add --dev @testing-library/react
yarn add --dev @testing-library/react @testing-library/dom
```

This library has `peerDependencies` listings for `react` and `react-dom`.
This library has `peerDependencies` listings for `react`, `react-dom` and
starting from RTL version 16 also `@testing-library/dom`.

_React Testing Library versions 13+ require React v18. If your project uses an
older version of React, be sure to install version 12:_
Expand Down
11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@
"author": "Kent C. Dodds <[email protected]> (https://kentcdodds.com)",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.12.5",
"@testing-library/dom": "^10.0.0",
"@types/react-dom": "^18.0.0"
"@babel/runtime": "^7.12.5"
},
"devDependencies": {
"@testing-library/dom": "^10.0.0",
"@testing-library/jest-dom": "^5.11.6",
"@types/react": "^18.3.1",
"@types/react-dom": "^18.3.0",
"chalk": "^4.1.2",
"dotenv-cli": "^4.0.0",
"jest-diff": "^29.7.0",
Expand All @@ -63,13 +63,18 @@
"typescript": "^4.1.2"
},
"peerDependencies": {
"@testing-library/dom": "^10.0.0",
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
"react": "^18.0.0",
"react-dom": "^18.0.0"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
},
"@types/react-dom": {
"optional": true
}
},
"eslintConfig": {
Expand Down

0 comments on commit a4744fa

Please sign in to comment.