Skip to content

Commit a4744fa

Browse files
eps1lonMatanBobi
andauthoredJun 3, 2024··
feat: Move @testing-library/dom and @types/react-dom to peer dependencies (#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 <matanbobi@gmail.com>
1 parent c1f2957 commit a4744fa

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed
 

‎README.md

+7-4
Original file line numberDiff line numberDiff line change
@@ -97,21 +97,24 @@ primary guiding principle is:
9797
## Installation
9898

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

102104
```
103-
npm install --save-dev @testing-library/react
105+
npm install --save-dev @testing-library/react @testing-library/dom
104106
```
105107

106108
or
107109

108110
for installation via [yarn][yarn]
109111

110112
```
111-
yarn add --dev @testing-library/react
113+
yarn add --dev @testing-library/react @testing-library/dom
112114
```
113115

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

116119
_React Testing Library versions 13+ require React v18. If your project uses an
117120
older version of React, be sure to install version 12:_

‎package.json

+8-3
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@
4545
"author": "Kent C. Dodds <me@kentcdodds.com> (https://kentcdodds.com)",
4646
"license": "MIT",
4747
"dependencies": {
48-
"@babel/runtime": "^7.12.5",
49-
"@testing-library/dom": "^10.0.0",
50-
"@types/react-dom": "^18.0.0"
48+
"@babel/runtime": "^7.12.5"
5149
},
5250
"devDependencies": {
51+
"@testing-library/dom": "^10.0.0",
5352
"@testing-library/jest-dom": "^5.11.6",
5453
"@types/react": "^18.3.1",
54+
"@types/react-dom": "^18.3.0",
5555
"chalk": "^4.1.2",
5656
"dotenv-cli": "^4.0.0",
5757
"jest-diff": "^29.7.0",
@@ -63,13 +63,18 @@
6363
"typescript": "^4.1.2"
6464
},
6565
"peerDependencies": {
66+
"@testing-library/dom": "^10.0.0",
6667
"@types/react": "^18.0.0",
68+
"@types/react-dom": "^18.0.0",
6769
"react": "^18.0.0",
6870
"react-dom": "^18.0.0"
6971
},
7072
"peerDependenciesMeta": {
7173
"@types/react": {
7274
"optional": true
75+
},
76+
"@types/react-dom": {
77+
"optional": true
7378
}
7479
},
7580
"eslintConfig": {

0 commit comments

Comments
 (0)
Please sign in to comment.