Skip to content

Commit 5cfa825

Browse files
committed
test: test ssr
1 parent 3c1af66 commit 5cfa825

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { expect, test } from 'vitest'
2+
import { editFile, isBuild, page, viteTestUrl } from '../../test-utils'
3+
4+
test('basic', async () => {
5+
await page.getByText('hydrated: true').click()
6+
await page.getByRole('button', { name: 'Count: 0' }).click()
7+
await page.getByRole('button', { name: 'Count: 1' }).click()
8+
await page.getByText('[virtual] test:virtual:ok').click()
9+
10+
const res = await page.request.get(viteTestUrl)
11+
expect(await res.text()).toContain('hydrated: <!-- -->false')
12+
})
13+
14+
test.runIf(!isBuild)('hmr', async () => {
15+
await page.goto(viteTestUrl)
16+
await page.getByRole('button', { name: 'Count: 0' }).click()
17+
18+
editFile('./src/app.tsx', (s) => s.replace('Count:', 'Count-x:'))
19+
await page.getByRole('button', { name: 'Count-x: 1' }).click()
20+
21+
editFile('./src/app.tsx', (s) => s.replace('Count-x:', 'Count-x-y:'))
22+
await page.getByRole('button', { name: 'Count-x-y: 2' }).click()
23+
24+
const res = await page.request.get(viteTestUrl)
25+
expect(await res.text()).toContain('Count-x-y')
26+
})

playground/rolldown-dev-ssr/src/app.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export function App() {
99
<h1>Rolldown SSR</h1>
1010
<Hydrated />
1111
<button onClick={() => setCount((c) => c + 1)}>Count: {count}</button>
12-
<pre>[virtual:test] {virtualTest}</pre>
12+
<pre>[virtual] {virtualTest}</pre>
1313
</div>
1414
)
1515
}

playground/rolldown-dev-ssr/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export default defineConfig({
6262
handler(id, _options) {
6363
if (id === '\0virtual:test') {
6464
debug('[load]', this.environment?.name)
65-
return `export default "virtual-ok"`
65+
return `export default "test:virtual:ok"`
6666
}
6767
},
6868
},

0 commit comments

Comments
 (0)