Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(replay): Switch to explicit vitest imports #13027

Merged
merged 1 commit into from
Jul 24, 2024

Conversation

AbhiPrasad
Copy link
Member

As per https://vitest.dev/config/#globals

By default, vitest does not provide global APIs for explicitness

I think we should follow vitest defaults here and explicitly import in the APIs that we need. This refactors our Replay SDK tests to do so.

ref #11084

This change also removes environment: 'jsdom' from the vite config in favour of explicitly adding jsdom environment via the @vitest-environment pragma to the specific test file that needs it. This should means that our non-browser tests are not polluted with jsdom globals, and that future writers have to explicitly opt-in to the behaviour.

@mydea
Copy link
Member

mydea commented Jul 24, 2024

Generally this is a good change IMHO, one thing I am not certain about is the explicit jsdom opt-in. It feels like we need this in most tests for replay, so I'd feel like for replay it would be OK to just have that on by default 🤔 @billyvg wdyt?

@AbhiPrasad
Copy link
Member Author

I am not certain about is the explicit jsdom opt-in.

Although this is extra boilerplate, I feel like this does a good job to communicate intent, and explicitly tells users that they are not in a completely Node.js environment.

It also makes migrating away from JSDOM easier, something we should evaluate. When vitest is more stable, I'd like to move all JSDOM tests into vitest browser mode: https://vitest.dev/guide/browser/ (powered by playwright), so we never get caught with jsdom incompatibility issues again.

@AbhiPrasad AbhiPrasad merged commit 92ce821 into develop Jul 24, 2024
120 checks passed
@AbhiPrasad AbhiPrasad deleted the abhi-vitest-replay-internal branch July 24, 2024 15:30
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.

3 participants