vitest-dev / vitest-browser-react

Render React components in Vitest Browser Mode
https://www.npmjs.com/package/vitest-browser-react
37 stars 2 forks source link

Error: Could not determine window of node. Node was [object Object] #1

Closed xeger closed 2 months ago

xeger commented 2 months ago

It seems that @vitest/browser/context isn't properly coordinating with vitest-browser-react; I'm not sure of the specifics.

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

Troubleshooting

👎 Tried swapping the order of render vs. setup 👎 Tried const user = userEvent; in case the setup is unnecessary

sheremet-va commented 2 months ago

This is not an error with this library, it's a bug in Vitest.