-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
feat: browserIssues and PRs related to the browser runnerIssues and PRs related to the browser runnerp4-importantViolate documented behavior or significantly improves performance (priority)Violate documented behavior or significantly improves performance (priority)
Description
Describe the bug
Also filed as vitest/vitest-browser-react#1 but I am cross posting here for visibility purposes.
It seems that @vitest/browser/context isn't properly coordinating with vitest-browser-react. The React rendering and verification work well by themselves, but when I try to fire any user events, the userEvent imported from @vitest/browser/context fails with an error.
Seems like the two pieces of @vitest/browser aren't communicating with ech other. (I know that vitest-browser-react is a separate package, but it integrates tightly with @vitest/browser, and in this case, the integration seems to be not quite right.)
Troubleshooting
👎 Tried swapping the order of render vs. setup
👎 Tried const user = userEvent; in case the setup is unnecessary
Reproduction
import { page, userEvent } from '@vitest/browser/context';
import { beforeEach, describe, expect, test } from 'vitest';
test('reproduction', () => {
const user = userEvent.setup();
const screen = page.render(<span>hello, world</span>);
await user.hover(page.getByRole('button'));
});This results in:
reproduction
Error: Could not determine window of node. Node was [object Object]
- /src/__tests__/reproduction.test.tsx:7:2
System Info
System:
OS: macOS 14.6.1
CPU: (12) arm64 Apple M3 Pro
Memory: 1.79 GB / 36.00 GB
Shell: 3.7.0 - /opt/homebrew/bin/fish
Binaries:
Node: 20.11.0 - ~/.asdf/installs/nodejs/20.11.0/bin/node
npm: 10.8.2 - ~/.asdf/plugins/nodejs/shims/npm
Browsers:
Chrome: 128.0.6613.114
Chrome Canary: 130.0.6694.0
Safari: 17.6
npmPackages:
@vitejs/plugin-react: ^4.2.1 => 4.3.1
@vitest/browser: 2.1.0-beta.6 => 2.1.0-beta.6
@vitest/coverage-istanbul: 2.1.0-beta.6 => 2.1.0-beta.6
@vitest/runner: 2.1.0-beta.6 => 2.1.0-beta.6
vite: ^5.2.0 => 5.4.2
vitest: 2.1.0-beta.6 => 2.1.0-beta.6Used Package Manager
npm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Metadata
Metadata
Assignees
Labels
feat: browserIssues and PRs related to the browser runnerIssues and PRs related to the browser runnerp4-importantViolate documented behavior or significantly improves performance (priority)Violate documented behavior or significantly improves performance (priority)