Skip to content

Comments

test: Real browser tests#9516

Open
reidbarber wants to merge 18 commits intomainfrom
vitest-browser-mode-tests
Open

test: Real browser tests#9516
reidbarber wants to merge 18 commits intomainfrom
vitest-browser-mode-tests

Conversation

@reidbarber
Copy link
Member

@reidbarber reidbarber commented Jan 24, 2026

Adds setup for using Vitest Browser Mode to run certain tests in real browsers (Chromium, Firefox, and WebKit).

Tests with the *.browser.test.{ts,tsx} pattern get run when running yarn test:browser.

Notes:

  • This currently doesn't run in CI, but we can enable that later if we want. These take a while to run, so we probably want to limit them to testing things that are difficult to test in our existing tests without mocking browser features that aren't available in jsdom. We can still rely on Chromatic for basic browser rendering.
  • This PR adds a single DropZone.browser.test.tsx to get us started. Unfortunately, I noticed our drag and drop events don't work with userEvent.dragAndDrop in Chromium because of how Playwright interfaces with Chromium, so I made a utility that falls back to manually firing the DragEvents in the expected order. Hopefully we don't have too many things like this to custom handle.

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

Run yarn test:browser or yarn test:browser run to run without watch mode.

🧢 Your Project:

@github-actions github-actions bot added the S2 label Feb 17, 2026
@rspbot
Copy link

rspbot commented Feb 17, 2026

@reidbarber reidbarber changed the title [WIP] test: add S2 tests test: Real browser tests Feb 17, 2026
@rspbot
Copy link

rspbot commented Feb 17, 2026

Copy link
Member

@LFDanLu LFDanLu left a comment

Choose a reason for hiding this comment

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

Happy to merge it in as is, we can discuss how specifics like run cadence, CI, and what tests to use this for after playing around with more test scenarios. Also curious if this easily extends to the more classic kind of browser tests where we send it to a page/build instead of calling render on our own written test case

"start:mcp": "yarn workspace @react-spectrum/s2-docs generate:md && yarn build:mcp && node packages/dev/mcp/s2/dist/index.js && node packages/dev/mcp/react-aria/dist/index.js",
"test:mcp": "yarn build:s2-docs && yarn build:mcp && node packages/dev/mcp/scripts/smoke-list-pages.mjs",
"test": "cross-env STRICT_MODE=1 VIRT_ON=1 yarn jest",
"test:browser": "vitest --config=vitest.browser.config.ts",
Copy link
Member

Choose a reason for hiding this comment

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

looks like we need to run yarn playwright install to download chromium and other browsers before this works. I assume we'd want to be as up to date as possible (and thus download fresh on every run?) but track what versions failed when that happens for browser specific bug logging. Alternatively we could store the browser builds somewhere I'd imagine and update only when desired

Copy link
Member

Choose a reason for hiding this comment

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

a bit unfortunate that we still have to mock/dispatch events here

Copy link
Member

Choose a reason for hiding this comment

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

I noticed that the tests were being run at a mobile device screen resolution, would be nice to have it run in desktop widths as well automatically. Also I assume there is the ability to run headless as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants