Skip to content

Commit 079feaf

Browse files
authored
test(rsc): fix flaky server restart test (#535)
1 parent 2966af5 commit 079feaf

File tree

2 files changed

+27
-26
lines changed

2 files changed

+27
-26
lines changed

packages/plugin-rsc/e2e/basic.test.ts

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,33 @@ test.describe('dev-default', () => {
1212
defineTest(f)
1313
})
1414

15+
test.describe('dev-initial', () => {
16+
const f = useFixture({ root: 'examples/basic', mode: 'dev' })
17+
18+
// verify css is collected properly on server startup (i.e. empty module graph)
19+
testNoJs('style', async ({ page }) => {
20+
await page.goto(f.url('./'))
21+
await expect(page.locator('.test-style-client')).toHaveCSS(
22+
'color',
23+
'rgb(255, 165, 0)',
24+
)
25+
await expect(page.locator('.test-style-server')).toHaveCSS(
26+
'color',
27+
'rgb(255, 165, 0)',
28+
)
29+
await expect(page.locator('.test-tw-client')).toHaveCSS(
30+
'color',
31+
// blue-500
32+
'rgb(0, 0, 255)',
33+
)
34+
await expect(page.locator('.test-tw-server')).toHaveCSS(
35+
'color',
36+
// red-500
37+
'rgb(255, 0, 0)',
38+
)
39+
})
40+
})
41+
1542
test.describe('build-default', () => {
1643
const f = useFixture({ root: 'examples/basic', mode: 'build' })
1744
defineTest(f)
@@ -656,15 +683,6 @@ function defineTest(f: Fixture) {
656683
'rgb(255, 0, 0)',
657684
)
658685
})
659-
660-
testNoJs('no FOUC after server restart @nojs', async ({ page }) => {
661-
const res = await page.request.get(f.url('/__test_restart'))
662-
expect(await res.text()).toBe('ok')
663-
await new Promise((r) => setTimeout(r, 100))
664-
await page.goto(f.url('./'))
665-
await testCss(page)
666-
await testTailwind(page)
667-
})
668686
})
669687

670688
test('temporary references @js', async ({ page }) => {

packages/plugin-rsc/examples/basic/vite.config.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,6 @@ export default defineConfig({
4545
}),
4646
// avoid ecosystem CI fail due to vite-plugin-inspect compatibility
4747
!process.env.ECOSYSTEM_CI && inspect(),
48-
{
49-
// test server restart scenario on e2e
50-
name: 'test-api',
51-
configureServer(server) {
52-
server.middlewares.use((req, res, next) => {
53-
const url = new URL(req.url!, 'http://localhost')
54-
if (url.pathname === '/__test_restart') {
55-
setTimeout(() => {
56-
server.restart()
57-
}, 10)
58-
res.end('ok')
59-
return
60-
}
61-
next()
62-
})
63-
},
64-
},
6548
{
6649
name: 'test-client-reference-tree-shaking',
6750
enforce: 'post',

0 commit comments

Comments
 (0)