diff --git a/CHANGELOG.md b/CHANGELOG.md
index 760947fc7e62..9f83b1fe2ab3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,7 +3,7 @@
### Features
- `[jest-config]` [**BREAKING**] Make `snapshotFormat` default to `escapeString: false` and `printBasicPrototype: false` ([#13036](https://github.com/facebook/jest/pull/13036))
-- `[jest-environment-jsdom]` [**BREAKING**] Upgrade to `jsdom@20` ([#13037](https://github.com/facebook/jest/pull/13037))
+- `[jest-environment-jsdom]` [**BREAKING**] Upgrade to `jsdom@20` ([#13037](https://github.com/facebook/jest/pull/13037), [#13058](https://github.com/facebook/jest/pull/13058))
- `[pretty-format]` [**BREAKING**] Remove `ConvertAnsi` plugin in favour of `jest-serializer-ansi-escapes` ([#13040](https://github.com/facebook/jest/pull/13040))
### Fixes
diff --git a/docs/UpgradingToJest29.md b/docs/UpgradingToJest29.md
index 182bf0bcb934..587535038ca0 100644
--- a/docs/UpgradingToJest29.md
+++ b/docs/UpgradingToJest29.md
@@ -30,7 +30,7 @@ If you want to keep the old behavior, you can set the `snapshotFormat` property
## JSDOM upgrade
-`jest-environment-jsdom` has upgraded `jsdom` from v19 to v20. Due to issues with `@types/jsdom`, if you extend this environment, you might run into type errors. See https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/60999#discussioncomment-3158685.
+`jest-environment-jsdom` has upgraded `jsdom` from v19 to v20. Note that _if_ you use `jest-environment-jsdom`, the minimum TypeScript version is set to `4.5`.
## `pretty-format`
diff --git a/packages/jest-environment-jsdom/package.json b/packages/jest-environment-jsdom/package.json
index 9b5bc6ac07f0..962c2c0584f7 100644
--- a/packages/jest-environment-jsdom/package.json
+++ b/packages/jest-environment-jsdom/package.json
@@ -20,6 +20,7 @@
"@jest/environment": "^29.0.0-alpha.0",
"@jest/fake-timers": "^29.0.0-alpha.0",
"@jest/types": "^29.0.0-alpha.0",
+ "@types/jsdom": "^20.0.0",
"@types/node": "*",
"jest-mock": "^29.0.0-alpha.0",
"jest-util": "^29.0.0-alpha.0",
diff --git a/packages/jest-environment-jsdom/src/index.ts b/packages/jest-environment-jsdom/src/index.ts
index 2412dc9b4652..7ae1345df4be 100644
--- a/packages/jest-environment-jsdom/src/index.ts
+++ b/packages/jest-environment-jsdom/src/index.ts
@@ -5,10 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
-///
-
import type {Context} from 'vm';
-// @ts-expect-error: TODO: we're missing v20 types
import {JSDOM, ResourceLoader, VirtualConsole} from 'jsdom';
import type {
EnvironmentContext,
@@ -30,8 +27,7 @@ type Win = Window &
};
export default class JSDOMEnvironment implements JestEnvironment {
- // TODO: make non-privat when we have `@types/jsdom` again
- private dom: JSDOM | null;
+ dom: JSDOM | null;
fakeTimers: LegacyFakeTimers | null;
fakeTimersModern: ModernFakeTimers | null;
global: Win;
@@ -44,7 +40,6 @@ export default class JSDOMEnvironment implements JestEnvironment {
const virtualConsole = new VirtualConsole();
virtualConsole.sendTo(context.console, {omitJSDOMErrors: true});
- // @ts-expect-error: TODO: we're missing v20 types
virtualConsole.on('jsdomError', error => {
context.console.error(error);
});
diff --git a/yarn.lock b/yarn.lock
index 4abf83c5ff6f..64658bf34958 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -5234,6 +5234,17 @@ __metadata:
languageName: node
linkType: hard
+"@types/jsdom@npm:^20.0.0":
+ version: 20.0.0
+ resolution: "@types/jsdom@npm:20.0.0"
+ dependencies:
+ "@types/node": "*"
+ "@types/tough-cookie": "*"
+ parse5: ^7.0.0
+ checksum: 13e67d31347e02d46ec6a23919b3ce39d86136665922a2a6cb977e216a2f46c22d2f025d0586a64ab492ebaa5f43da669b6f173a5a8cfd3e3bb7c9d19b6cfa9e
+ languageName: node
+ linkType: hard
+
"@types/json-schema@npm:*, @types/json-schema@npm:^7.0.4, @types/json-schema@npm:^7.0.5, @types/json-schema@npm:^7.0.8, @types/json-schema@npm:^7.0.9":
version: 7.0.11
resolution: "@types/json-schema@npm:7.0.11"
@@ -5612,6 +5623,13 @@ __metadata:
languageName: node
linkType: hard
+"@types/tough-cookie@npm:*":
+ version: 4.0.2
+ resolution: "@types/tough-cookie@npm:4.0.2"
+ checksum: e055556ffdaa39ad85ede0af192c93f93f986f4bd9e9426efdc2948e3e2632db3a4a584d4937dbf6d7620527419bc99e6182d3daf2b08685e710f2eda5291905
+ languageName: node
+ linkType: hard
+
"@types/trusted-types@npm:^2.0.2":
version: 2.0.2
resolution: "@types/trusted-types@npm:2.0.2"
@@ -13262,6 +13280,7 @@ __metadata:
"@jest/fake-timers": ^29.0.0-alpha.0
"@jest/test-utils": ^29.0.0-alpha.0
"@jest/types": ^29.0.0-alpha.0
+ "@types/jsdom": ^20.0.0
"@types/node": "*"
jest-mock: ^29.0.0-alpha.0
jest-util: ^29.0.0-alpha.0