Skip to content

Conversation

@crisbeto
Copy link
Member

@crisbeto crisbeto commented Nov 24, 2025

Fixes that we were hitting an error due to the DOM implementation that Vitest is using when constructing events.

Fixes #32389.

@crisbeto crisbeto requested a review from a team as a code owner November 24, 2025 09:39
@crisbeto crisbeto added the target: patch This PR is targeted for the next patch release label Nov 24, 2025
@crisbeto crisbeto requested review from mmalerba and ok7sai and removed request for a team November 24, 2025 09:39
Fixes that we were hitting an error due to the DOM implementation that Vitest is using when constructing events.
@crisbeto crisbeto force-pushed the 32389/vitest-events branch from ff5b46a to 0d6642c Compare November 25, 2025 12:08
// Passing `window` as the `view` on for events when the environment is using jsdom
// ends up throwing `member view is not of type Window` (see #32389). Leave it as
// `undefined` for such cases.
return typeof window !== 'undefined' && window && !(window as Window & {jsdom?: unknown}).jsdom
Copy link
Contributor

@alan-agius4 alan-agius4 Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT, redundant check

Suggested change
return typeof window !== 'undefined' && window && !(window as Window & {jsdom?: unknown}).jsdom
return typeof window !== 'undefined' && !(window as Window & {jsdom?: unknown}).jsdom

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The check is there because technically window can be null which is typeof === 'object'.

Copy link
Contributor

@alan-agius4 alan-agius4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just one NIT

@crisbeto crisbeto added the action: merge The PR is ready for merge by the caretaker label Nov 25, 2025
@crisbeto crisbeto merged commit d41d397 into angular:main Nov 25, 2025
22 of 25 checks passed
@crisbeto
Copy link
Member Author

This PR was merged into the repository. The changes were merged into the following branches:

crisbeto added a commit that referenced this pull request Nov 25, 2025
Fixes that we were hitting an error due to the DOM implementation that Vitest is using when constructing events.

(cherry picked from commit d41d397)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: cdk/testing target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(mouse): Click triggered with TestHarnesses causes crashes on Vitest using jsdom

2 participants