playwright/tests/components/ct-react17/tests/react-router.spec.tsx

15 lines
606 B
TypeScript
Raw Normal View History

2023-04-10 00:11:31 +02:00
import { test, expect } from '@playwright/experimental-ct-react17';
import App from '@/App';
import type { HooksConfig } from '../playwright';
test('navigate to a page by clicking a link', async ({ page, mount }) => {
const component = await mount<HooksConfig>(<App />, {
hooksConfig: { routing: true },
});
await expect(component.getByRole('main')).toHaveText('Login');
await expect(page).toHaveURL('/');
await component.getByRole('link', { name: 'Dashboard' }).click();
await expect(component.getByRole('main')).toHaveText('Dashboard');
await expect(page).toHaveURL('/dashboard');
});