vmware-clarity / core

Clarity is a scalable, accessible, customizable, open-source design system built with web components. Works with any JavaScript framework, created for enterprises, and designed to be inclusive.
https://clarity.design
MIT License
161 stars 42 forks source link

fix(react): fix jsdom react testing with vitest #261

Closed antoninbas closed 11 months ago

antoninbas commented 11 months ago

Replace isJestTest with more general isJsdomTest.

The code had a workaround to ensure compatibility with Jest + Jsdom. The value of process.env.JEST_WORKER_ID was used to determine whether the execution environment was Jest. To ensure compatibility with other test frameworks, and in particular Vitest, we use a more general test to determine whether to apply the workaround.

Fixes #260

PR Checklist

PR Type

What kind of change does this PR introduce?

What is the current behavior?

Issue Number: #260

What is the new behavior?

No errors when running tests with non-jest testing frameworks (e.g. vitest).

Does this PR introduce a breaking change?

antoninbas commented 11 months ago

@kevinbuhmann I had to update the PR as I didn't run npm run public-api:update correctly the first time. PTAL.

antoninbas commented 11 months ago

@kevinbuhmann are we good to merge this, or is anything else needed from me?

kevinbuhmann commented 11 months ago

@kevinbuhmann are we good to merge this, or is anything else needed from me?

The build is done now, so I will merge this. Thanks!

github-actions[bot] commented 11 months ago

Hi there 👋, this is an automated message. To help Clarity keep track of discussions, we automatically lock closed PRs after 14 days. Please look for another open issue or open a new issue with updated details and reference this one as necessary.