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

app.spec.ts

36 lines1.4 KB

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