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

transition.spec.ts

37 lines991 Bytes

1import { expect, test } from '@playwright/test'
2​
3test('react-query transitions keep previous data during navigation', async ({
4 page,
5}) => {
6 await page.goto('/transition/count/query')
7​
8 await expect(page.getByTestId('n-value')).toContainText('n: 1')
9 await expect(page.getByTestId('double-value')).toContainText('double: 2')
10​
11 const bodySnapshots: Array<string> = []
12​
13 const interval = setInterval(async () => {
14 const text = await page
15 .locator('body')
16 .textContent()
17 .catch(() => '')
18 if (text) bodySnapshots.push(text)
19 }, 50)
20​
21 await page.getByTestId('increase-button').click()
22​
23 await page.waitForTimeout(200)
24​
25 clearInterval(interval)
26​
27 await expect(page.getByTestId('n-value')).toContainText('n: 2', {
28 timeout: 2_000,
29 })
30 await expect(page.getByTestId('double-value')).toContainText('double: 4', {
31 timeout: 2_000,
32 })
33​
34 const sawLoading = bodySnapshots.some((text) => text.includes('Loading...'))
35​
36 expect(sawLoading).toBeFalsy()
37})