Skip to content

test: set up vitest browser mode test environment #11877

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

Merged
merged 11 commits into from
Apr 9, 2025

Conversation

jcfranco
Copy link
Member

@jcfranco jcfranco commented Apr 7, 2025

Related Issue: #11268

Summary

Some of Lumina's testing utils and patterns (e.g., mount) depend or work best on Vitest's experimental browser mode, so this PR enables testing with it. This supports E2E and/or spec tests that would be simpler to write with this mode (e.g., #7060).

Tests meant for this mode should use the following naming pattern: <name>.browser.(spec|e2e).tsx? (see example).

Note: Until browser mode is stable, continue using the usual E2E or spec tests unless a browser-mode test is specifically needed.

@jcfranco jcfranco requested a review from benelan as a code owner April 7, 2025 04:28
@jcfranco jcfranco marked this pull request as draft April 7, 2025 04:28
@jcfranco jcfranco added the skip visual snapshots Pull requests that do not need visual regression testing. label Apr 7, 2025
@jcfranco jcfranco marked this pull request as ready for review April 8, 2025 17:07
@jcfranco jcfranco requested a review from alisonailea as a code owner April 8, 2025 17:07
@jcfranco jcfranco requested review from eriklharper, driskull and Elijbet and removed request for alisonailea April 8, 2025 17:09
Copy link
Member

@driskull driskull left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Member

@benelan benelan left a comment

Choose a reason for hiding this comment

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

I likey!

"test": "concurrently \"npm:test:stable\" \"npm:test:experimental\"",
"test:stable": "STABLE_TESTS=true vitest run",
"test:experimental": "EXPERIMENTAL_TESTS=true vitest run --browser.headless",
"test:watch": "npm run test:watch:stable && npm run test:watch:experimental",
Copy link
Member

Choose a reason for hiding this comment

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

Did you confirm test:watch works? I don't think test:experimental will run because test:stable won't exit. You may need to use concurrently like the test script does.

Copy link
Member Author

Choose a reason for hiding this comment

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

Great catch. Will fix!

Copy link
Member Author

@jcfranco jcfranco Apr 9, 2025

Choose a reason for hiding this comment

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

Used concurrently + passthrough options. One thing to note is that interactive watch mode won't work as before since both test runners might conflict when handling input. I've updated the contributing doc with this info.

@jcfranco
Copy link
Member Author

jcfranco commented Apr 9, 2025

Merging! @benelan LMK if there's any additional tweaks needed for the test:watch script + doc.

@jcfranco jcfranco merged commit a9794af into dev Apr 9, 2025
10 checks passed
@jcfranco jcfranco deleted the jcfranco/11268-set-up-vitest-browser-mode branch April 9, 2025 15:51
@github-actions github-actions bot added this to the 2025-04-29 - Apr Milestone milestone Apr 9, 2025
jcfranco added a commit that referenced this pull request Apr 10, 2025
**Related Issue:** N/A  

## Summary  

Adds passthrough arg support to `test` script missed in
#11877.
benelan added a commit that referenced this pull request Apr 15, 2025
**Related Issue:** #11877

## Summary

Make vitest default to the stable tests when the `EXPERIMENTAL_TESTS`
environment variable is not set. Previously, `npx vitest` would not find
any tests to run.

This change fixes the test runner integrations provided by some IDEs
(including neovim and vscode).

NOTE: We can probably get rid of the `STABLE_TESTS` environment 
variable with this change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip visual snapshots Pull requests that do not need visual regression testing.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants