Use screen terminology instead of page as documented by vite-browser-react

This commit is contained in:
Alejandro Celaya
2026-08-16 21:08:53 +02:00
parent c5c994a603
commit 31531c1f87
18 changed files with 213 additions and 210 deletions

View File

@@ -14,15 +14,15 @@ describe('<NotFound />', () => {
it('passes a11y checks', () => checkAccessibility(setUp()));
it('shows expected error title', async () => {
const page = await setUp();
await expect.element(page.getByText('Oops! We could not find requested route.')).toBeInTheDocument();
const screen = await setUp();
await expect.element(screen.getByText('Oops! We could not find requested route.')).toBeInTheDocument();
});
it('shows expected error message', async () => {
const page = await setUp();
const screen = await setUp();
await expect
.element(
page.getByText(
screen.getByText(
"Use your browser's back button to navigate to the page you have previously come from, or just press this button.",
),
)
@@ -34,8 +34,8 @@ describe('<NotFound />', () => {
[{ to: '/foo/bar', children: 'Hello' }, '/foo/bar', 'Hello'],
[{ to: '/baz-bar', children: <>Foo</> }, '/baz-bar', 'Foo'],
])('shows expected link and text', async (props, expectedLink, expectedText) => {
const page = await setUp(props);
const link = page.getByRole('link');
const screen = await setUp(props);
const link = screen.getByRole('link');
await expect.element(link).toHaveAttribute('href', expectedLink);
await expect.element(link).toHaveTextContent(expectedText);