|
1 | | -import { expect, test } from 'vitest'; |
| 1 | +/// <reference types="@vitest/browser/providers/playwright" /> |
2 | 2 | import { render } from '@solidjs/testing-library'; |
3 | | -import user from '@testing-library/user-event'; |
| 3 | +import { page } from '@vitest/browser/context'; |
| 4 | +import { expect, test } from 'vitest'; |
4 | 5 |
|
5 | 6 | import App from '../src/App.jsx'; |
6 | 7 |
|
7 | 8 | test('App', async () => { |
8 | | - const { getByText } = render(() => <App />); |
9 | | - |
10 | | - const counterTitle = getByText('Counter'); |
| 9 | + const root = page.elementLocator(render(() => <App />).baseElement); |
11 | 10 |
|
12 | | - const count = counterTitle.nextElementSibling as HTMLElement; |
13 | | - expect(count).instanceOf(HTMLElement); |
14 | | - expect(count.innerHTML).toContain('Count: 0'); |
| 11 | + const count = root.getByText('Count:'); |
| 12 | + await expect.element(count).toHaveTextContent('Count: 0'); |
15 | 13 |
|
16 | | - const incrementButton = getByText('Increment'); |
17 | | - await user.click(incrementButton); |
18 | | - expect(count.innerHTML).toContain('Count: 1'); |
| 14 | + const incrementButton = root.getByText('Increment'); |
| 15 | + await incrementButton.click(); |
| 16 | + await expect.element(count).toHaveTextContent('Count: 1'); |
19 | 17 |
|
20 | | - const decrementButton = getByText('Decrement'); |
21 | | - await user.click(decrementButton); |
22 | | - expect(count.innerHTML).toContain('Count: 0'); |
| 18 | + const decrementButton = root.getByText('Decrement'); |
| 19 | + await decrementButton.click(); |
| 20 | + await expect.element(count).toHaveTextContent('Count: 0'); |
23 | 21 | }); |
0 commit comments