Skip to content
Source
Sign inSign up
TanStack/router
Open History to see the last commit

app.spec.ts

36 lines1.3 KB

1import { expect, test } from '@playwright/test'
2​
3test('Navigating to post', async ({ page }) => {
4 await page.goto('/')
5​
6 await page.getByRole('link', { name: 'Posts' }).click()
7 await page.getByRole('link', { name: 'sunt aut facere repe' }).click()
8 await page.getByRole('link', { name: 'Deep View' }).click()
9 await expect(page.getByRole('heading')).toContainText('sunt aut facere')
10})
11​
12test('Navigating to user', async ({ page }) => {
13 await page.goto('/')
14​
15 await page.getByRole('link', { name: 'Users' }).click()
16 await page.getByRole('link', { name: 'Leanne Graham' }).click()
17 await expect(page.getByRole('heading')).toContainText('Leanne Graham')
18})
19​
20test('Navigating nested layouts', async ({ page }) => {
21 await page.goto('/')
22​
23 await page.getByRole('link', { name: 'Layout', exact: true }).click()
24 await page.getByRole('link', { name: 'Layout A' }).click()
25 await expect(page.locator('body')).toContainText("I'm A!")
26 await page.getByRole('link', { name: 'Layout B' }).click()
27 await expect(page.locator('body')).toContainText("I'm B!")
28})
29​
30test('Navigating to a not-found route', async ({ page }) => {
31 await page.goto('/')
32​
33 await page.getByRole('link', { name: 'This Route Does Not Exist' }).click()
34 await page.getByRole('link', { name: 'Start Over' }).click()
35 await expect(page.getByRole('heading')).toContainText('Welcome Home!')
36})