-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
chore: use real VITEST_API_TOKEN for ui dev
#10279
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
sheremet-va
merged 21 commits into
vitest-dev:main
from
hi-ogawa:chore-use-vitest-api-token-for-ui-dev
May 7, 2026
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
5402912
chore: use VITEST_API_TOKEN for ui dev
hi-ogawa f4a0669
wip: browser-dev-preview
hi-ogawa 69545d5
cleanup
hi-ogawa 4a90b06
fix: disable on test
hi-ogawa 289e163
cleanup
hi-ogawa 3ea242c
wip browser dev
hi-ogawa f969d3f
fix regex
hi-ogawa d8bd779
fix: always generate api token
hi-ogawa b450fd6
cleanup
hi-ogawa 688f360
fix(ui): proxy browser preview state in dev
hi-ogawa 1a85777
chore(ui): rename browser dev env vars
hi-ogawa 3b9cd78
tweak
hi-ogawa 7d22f69
wip
hi-ogawa f55780a
polish
hi-ogawa d98b5a6
cleanup
hi-ogawa 78bee92
cleanup
hi-ogawa 754700e
docs(ui): clarify dev server ports
hi-ogawa 80c99f9
nit
hi-ogawa 579f7cf
chore(ui): avoid assert in dev script plugin
hi-ogawa 2557f18
bloat
hi-ogawa 9cdb55a
deslop
hi-ogawa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,25 +1,56 @@ | ||
| At project root, create terminals with each of the following commands: | ||
| # @vitest/ui Development | ||
|
|
||
| ## UI | ||
|
|
||
| Use this setup for developing UI features with Vite HMR. It serves the UI from a separate dev server, so it can differ from the exact `vitest --ui` runtime path. | ||
|
|
||
| Start the UI dev server: | ||
|
|
||
| ```bash | ||
| # Align with the API port configured in test/unit/vite.config.ts. | ||
| VITE_PORT=3023 pnpm -C packages/ui dev:client | ||
| ``` | ||
|
|
||
| Start a Vitest UI/API server for any test project you want to use as the backend. For example, from the repository root this runs the `test/unit` suite with UI enabled: | ||
|
|
||
| ```bash | ||
| pnpm test --ui --open=false | ||
| ``` | ||
|
|
||
| The UI dev server only needs a real Vitest UI/API server to connect to; the backend can be `test/unit`, `packages/ui`, or another suite. | ||
|
|
||
| Open the URL printed by the UI dev server, usually `http://localhost:5173/`. | ||
|
|
||
| The UI dev server connects to the Vitest UI/API server on port `51204` by default. The root `test/unit` suite uses port `3023`, so the command above sets `VITE_PORT=3023`. If you use another backend port, pass the same port to the UI dev server: | ||
|
|
||
| ```bash | ||
| nr ui:dev | ||
| VITE_PORT=12345 pnpm -C packages/ui dev:client | ||
| ``` | ||
|
|
||
| ```bash | ||
| nr test --api | ||
| pnpm test --ui --open=false --api=12345 | ||
| ``` | ||
|
|
||
| As the last command, you can use any of the available tests suites instead. Make sure that they run at 51204 port or specify a custom port with `VITE_PORT` environmental variable when running the first command. For example, | ||
| ## Browser Mode UI | ||
|
|
||
| Use this setup for developing Browser Mode UI features with Vite HMR. It serves the Browser Mode UI from the UI dev server and injects state from a real browser-mode Vitest server. | ||
|
|
||
| Start a browser-mode Vitest server: | ||
|
|
||
| ```bash | ||
| VITE_PORT=3200 nr ui:dev | ||
| pnpm -C packages/ui test:ui --browser.headless --ui --open=false | ||
| ``` | ||
|
|
||
| Start the UI dev server in browser preview mode: | ||
|
|
||
| ```bash | ||
| nr test --api=3200 | ||
| BROWSER_DEV=true pnpm -C packages/ui dev:client | ||
| ``` | ||
|
|
||
| Open the browser at the URL printed by the first command. For example, `http://localhost:5173/`. If you see a connection error, it means the port is specified incorrectly. | ||
| Open the URL printed by the UI dev server, usually `http://localhost:5173/`. | ||
|
|
||
| To preview the browser tab, uncomment the "browser-dev-preview" plugin in `vite.config.ts`. | ||
| The UI dev server fetches browser runner state from the browser runner server on port `63315` by default. If Vitest prints a different browser runner port, pass it to the UI dev server: | ||
|
|
||
| To configure the browser state, update the `__vitest_browser_runner__` object in `browser.dev.js`. | ||
| ```bash | ||
| BROWSER_DEV_PORT=63316 BROWSER_DEV=true pnpm -C packages/ui dev:client | ||
| ``` |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.