-
Hi! I'm trying to achieve something similar I would do with testing-library/react, but using the Browser Mode API:
test('types into the search', async () => {
const { getByRole, getByText } = render(<Search />)
const input = getByRole('input', { name: 'search' })
await userEvent.fill(input, 'Browser Mode')
await expect.element(getByText('Searching for Browser Mode')).toBeInTheDocument()
}) I have tried test('types into the search', async () => {
render(<Search />)
const input = await page.getByRole('input', { name: 'search' })
await input.fill('Browser Mode');
await expect.element(page.getByText('Searching for Browser Mode')).toBeInTheDocument()
}) However, both of these time out:
I'm sure I'm missing something simple here I just can't spot what. Here's the repo: https://github.com/akoskm/vitest-browser-mode Any help is appreciated. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Confusingly, aria role is - getByRole('input', { name: 'search' })
+ getByRole('textbox', { name: 'search' }) Also if you see this log, you should add
Also I just noticed |
Beta Was this translation helpful? Give feedback.
Confusingly, aria role is
textbox
instead ofinput
Also if you see this log, you should add
optimizeDeps.include: ['react/jsx-dev-runtime']
Also I just noticed
vitest
is not inpackage.json
. It works onnpm
, but it should be explicitly added…