Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: re-add @types/jsdom #13058

Merged
merged 3 commits into from
Jul 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/UpgradingToJest29.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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