Skip to content

Commit

Permalink
Revert "feat: upgrade to jsdom@20 (jestjs#13037)"
Browse files Browse the repository at this point in the history
This reverts commit 73de40d.
  • Loading branch information
SimenB committed Jul 24, 2022
1 parent 837af9e commit 93be500
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/UpgradingToJest29.md
Expand Up @@ -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`

Expand Down
1 change: 1 addition & 0 deletions packages/jest-environment-jsdom/package.json
Expand Up @@ -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",
Expand Down
7 changes: 1 addition & 6 deletions packages/jest-environment-jsdom/src/index.ts
Expand Up @@ -5,10 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

/// <reference lib="dom" />

import type {Context} from 'vm';
// @ts-expect-error: TODO: we're missing v20 types
import {JSDOM, ResourceLoader, VirtualConsole} from 'jsdom';
import type {
EnvironmentContext,
Expand All @@ -30,8 +27,7 @@ type Win = Window &
};

export default class JSDOMEnvironment implements JestEnvironment<number> {
// TODO: make non-privat when we have `@types/jsdom` again
private dom: JSDOM | null;
dom: JSDOM | null;
fakeTimers: LegacyFakeTimers<number> | null;
fakeTimersModern: ModernFakeTimers | null;
global: Win;
Expand All @@ -44,7 +40,6 @@ export default class JSDOMEnvironment implements JestEnvironment<number> {

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);
});
Expand Down
19 changes: 19 additions & 0 deletions yarn.lock
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 93be500

Please sign in to comment.