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

app.spec.ts

31 lines1.0 KB

1import { existsSync } from 'node:fs'
2import { join } from 'node:path'
3import { expect } from '@playwright/test'
4import { test } from '@tanstack/router-e2e-utils'
5​
6test('returns the correct user agent', async ({ page }) => {
7 await page.goto('/')
8 await expect(page.getByTestId('message')).toHaveText(
9 'Running in Cloudflare-Workers',
10 )
11})
12​
13test('returns the correct value from a Cloudflare binding', async ({
14 page,
15}) => {
16 await page.goto('/')
17 await expect(page.getByTestId('myVar')).toHaveText('Hello from Cloudflare')
18})
19​
20test('prerender with Cloudflare Workers runtime', async ({ page }) => {
21 // Verify the static page was prerendered during build
22 const distDir = join(process.cwd(), 'dist', 'client')
23 expect(existsSync(join(distDir, 'static', 'index.html'))).toBe(true)
24​
25 // Verify the page loads correctly
26 await page.goto('/static')
27 await expect(page.getByTestId('static-heading')).toHaveText('Static Page')
28 await expect(page.getByTestId('static-content')).toHaveText(
29 'The value is Hello from Cloudflare',
30 )
31})