Skip to content

feat(vitest): expose jsdom global if jsdom environment is enabled - #5155

Merged
sheremet-va merged 3 commits into
vitest-dev:mainfrom
sheremet-va:feat/expose-jsdom
Feb 8, 2024
Merged

feat(vitest): expose jsdom global if jsdom environment is enabled#5155
sheremet-va merged 3 commits into
vitest-dev:mainfrom
sheremet-va:feat/expose-jsdom

Conversation

@sheremet-va

@sheremet-va sheremet-va commented Feb 8, 2024

Copy link
Copy Markdown
Member

Description

This PR adds a global jsdom variable that you can use to reconfigure the current environment if you use JSDOM:

jsdom.reconfigure({ url: 'https://examples.new.com' })

This is particularly useful in vmThreads and vmForks pool where you cannot reconfigure the current location by reassigning the variable.

If you need TypeScript to recognize it, add vitest/jsdom to your types in tsconfig.json file:

{
  "compilerOptions": {
    "types": ["vitest/jsdom"]
  }
}

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.

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:.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant