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

app.spec.ts

33 lines1.3 KB

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