Skip to content

Commit 0d1e09a

Browse files
authored
Revert @testing-library/jest-dom v6 upgrade (#9713)
This reverts #9673 and #9711. With v6 of `@testing-library/jest-dom`, `yarn rw type-check` fails in Redwood projects because it can't locate the types for `@testing-libary/jest-dom`. They absorbed the definitely types package (`@types/testing-library__jest-dom`) in this PR: testing-library/jest-dom#511. Here's an example of a failing run: https://github.com/redwoodjs/redwood/actions/runs/7213177056/job/19668365614?pr=9708. The logical thing to do is remove `@testing-libary/jest-dom` from the `types` array in `web/tsconfig.json`, but when we do that we get a different failure from TS saying that it doesn't understand the extended matchers provided by `testing-library/jest-dom` like `toBeInTheDocument`. @Tobbe filed an issue in their repo here testing-library/jest-dom#559. In the PR I linked to, the maintainer notes that... > But in my local testing with the changes in this PR, following the Readme was sufficient to get full auto-complete support even for JS-only users. As long as they have a jest-setup file that imports the bare export and add a dependency on @types/jest, recent versions of VS Code will figure it out. Users don't have jest setup files in their project (we just point to a jest preset) or `@types/jest` as an explicit dev dependency. I took a look at it but couldn't crack it today. Instead of holding up other PRs in CI, better to revert it for now and come back to later when we have more leads.
1 parent 08aae1f commit 0d1e09a

21 files changed

+58
-48
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"@faker-js/faker": "8.0.2",
6767
"@npmcli/arborist": "7.2.2",
6868
"@playwright/test": "1.40.1",
69-
"@testing-library/jest-dom": "6.1.5",
69+
"@testing-library/jest-dom": "5.17.0",
7070
"@testing-library/react": "14.1.2",
7171
"@testing-library/user-event": "14.5.1",
7272
"@types/babel__generator": "7.6.7",

packages/auth/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"devDependencies": {
3030
"@babel/cli": "7.23.4",
3131
"@babel/core": "^7.22.20",
32-
"@testing-library/jest-dom": "6.1.5",
32+
"@testing-library/jest-dom": "5.17.0",
3333
"@testing-library/react": "14.1.2",
3434
"jest": "29.7.0",
3535
"msw": "1.3.2",

packages/auth/src/__tests__/AuthProvider.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
configure,
1111
} from '@testing-library/react'
1212
import { renderHook, act } from '@testing-library/react'
13-
import '@testing-library/jest-dom/jest-globals'
13+
import '@testing-library/jest-dom/extend-expect'
1414
import { graphql } from 'msw'
1515
import { setupServer } from 'msw/node'
1616

packages/forms/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,13 @@
3131
"@babel/cli": "7.23.4",
3232
"@babel/core": "^7.22.20",
3333
"@testing-library/dom": "9.3.3",
34-
"@testing-library/jest-dom": "6.1.5",
34+
"@testing-library/jest-dom": "5.17.0",
3535
"@testing-library/react": "14.1.2",
3636
"@testing-library/user-event": "14.5.1",
3737
"@types/pascalcase": "1.0.3",
3838
"@types/react": "18.2.37",
3939
"@types/react-dom": "18.2.15",
40+
"@types/testing-library__jest-dom": "5.14.9",
4041
"graphql": "16.8.1",
4142
"jest": "29.7.0",
4243
"nodemon": "3.0.2",

packages/router/src/__tests__/location.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { render } from '@testing-library/react'
2-
import '@testing-library/jest-dom/jest-globals'
2+
import '@testing-library/jest-dom/extend-expect'
33

44
import { LocationProvider, useLocation } from '../location'
55

packages/router/src/__tests__/nestedSets.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react'
22
import type { ReactNode } from 'react'
33

4-
import '@testing-library/jest-dom/jest-globals'
4+
import '@testing-library/jest-dom/extend-expect'
55
import { act, render } from '@testing-library/react'
66

77
import { navigate, Route, Router } from '../'

packages/router/src/__tests__/route-announcer.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react'
22

33
import { render, waitFor, act } from '@testing-library/react'
4-
import '@testing-library/jest-dom/jest-globals'
4+
import '@testing-library/jest-dom/extend-expect'
55

66
import { getAnnouncement } from '../a11yUtils'
77
import { navigate } from '../history'

packages/router/src/__tests__/route-focus.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { render, waitFor } from '@testing-library/react'
2-
import '@testing-library/jest-dom/jest-globals'
2+
import '@testing-library/jest-dom/extend-expect'
33

44
import { getFocus } from '../a11yUtils'
55
import RouteFocus from '../route-focus'

packages/router/src/__tests__/routeScrollReset.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
22

3-
import '@testing-library/jest-dom/jest-globals'
3+
import '@testing-library/jest-dom/extend-expect'
44
import { act, cleanup, render, screen } from '@testing-library/react'
55

66
import { navigate } from '../history'

packages/router/src/__tests__/router.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jest.mock('../util', () => {
2020

2121
import React, { useEffect, useState } from 'react'
2222

23-
import '@testing-library/jest-dom/jest-globals'
23+
import '@testing-library/jest-dom/extend-expect'
2424
import {
2525
act,
2626
configure,

0 commit comments

Comments
 (0)