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

client-output.spec.ts

32 lines1013 Bytes

1import { expect } from '@playwright/test'
2import { test } from '@tanstack/router-e2e-utils'
3​
4test.skip(
5 process.env.TSS_RSB_CLIENT_OUTPUT !== 'iife',
6 'IIFE client output assertions only run in rsbuild/ssr/iife mode',
7)
8​
9test('SSR HTML emits IIFE client scripts and classic script preloads', async ({
10 page,
11}) => {
12 const response = await page.goto('/posts')
13 const html = await response!.text()
14​
15 expect(html).not.toContain('rel="modulepreload"')
16 expect(html).toMatch(/<link[^>]+rel="preload"[^>]+as="script"/)
17​
18 const clientEntry = html.match(
19 /<script\b[^>]+src="([^"]*\/assets\/js\/index[^"]*)"[^>]*>/,
20 )
21 expect(clientEntry).toBeTruthy()
22 expect(clientEntry![0]).toContain('async')
23 expect(clientEntry![0]).not.toContain('type="module"')
24​
25 await expect(
26 page.getByRole('link', { name: 'sunt aut facere repe' }),
27 ).toBeVisible()
28​
29 await page.getByRole('link', { name: 'sunt aut facere repe' }).click()
30​
31 await expect(page.getByRole('heading')).toContainText('sunt aut facere')
32})