fix(jsdom): support AbortSignal API by sheremet-va · Pull Request #8704 · vitest-dev/vitest

@sheremet-va

Description

Fixes #8563

In jsdom AbortSignal API is used only in addEventListener.

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.
  • Please check Allow edits by maintainers to make review process faster. Note that this option is not available for repositories that are owned by Github organizations.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

@sheremet-va

@netlify

@sheremet-va

hi-ogawa

})
const clearWindowErrors = catchWindowErrors(dom.window as any)

patchAddEventListener(dom.window)

Choose a reason for hiding this comment

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

Shouldn't this unpatch on teardown?

Choose a reason for hiding this comment

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

teardown removes the EventTarget from global so I don't think it needs to be unpatched

Choose a reason for hiding this comment

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

Right, I wondered about that, but just in case? I'm fine either way.

Choose a reason for hiding this comment

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

Ok, let's add it just in case

hi-ogawa

})
const clearWindowErrors = catchWindowErrors(dom.window as any)

patchAddEventListener(dom.window)

Choose a reason for hiding this comment

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

Right, I wondered about that, but just in case? I'm fine either way.

AriPerkkio

Choose a reason for hiding this comment

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

Looks good. Patching globals just for JSDOM is fine as it's already simulating so much.

@sheremet-va

This was referenced

Nov 3, 2025