Closed antoninbas closed 1 year ago
This code checks whether the execution environment is Jest: https://github.com/vmware-clarity/core/blob/b21b14633259f717f25d7881ca1d43d08a0a8822/projects/core/src/internal/utils/environment.ts#L13-L15
Maybe we could extent this to check for Vitest as well. I will try it out.
Hi there 👋, this is an automated message. To help Clarity keep track of discussions, we automatically lock closed issues after 14 days. Please look for another open issue or open a new issue with updated details and reference this one as necessary.
Describe the bug
When using Clarity React, and testing with Vitest (jsdom environment) + React Testing Library, I observe the following errors:
How to reproduce
I have created a simple repository to reproduce the issue: https://github.com/antoninbas/clarity-react-vitest-jsdom-bug
Steps to reproduce the behavior:
git clone https://github.com/antoninbas/clarity-react-vitest-jsdom-bug.git
cd clarity-react-vitest-jsdom-bug
yarn install
yarn test
Expected behavior
The test should pass without any error.
Versions
Clarity project:
Clarity version:
Framework:
Framework version: React 18
Additional notes
I tried multiple versions of jsdom. This is the same issue as https://github.com/vmware-archive/clarity/issues/5985. The proposed workaround still works for me fortunately, but it doesn't seem that the issue was completely fixed. Surprisingly, I didn't run into this issue when using CRA + Jest (before migrating to Vite + Vitest). Tests were also running in jsdom.