-
-
Notifications
You must be signed in to change notification settings - Fork 242
Expand file tree
/
Copy pathreact-compiler.test.ts
More file actions
52 lines (44 loc) · 1.54 KB
/
react-compiler.test.ts
File metadata and controls
52 lines (44 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { expect, test } from '@playwright/test'
import { setupInlineFixture, useFixture } from './fixture'
import { waitForHydration } from './helper'
import { defineStarterTest } from './starter'
test.describe(() => {
const root = 'examples/e2e/temp/react-compiler'
test.beforeAll(async () => {
await setupInlineFixture({
src: 'examples/starter',
dest: root,
files: {
'vite.config.base.ts': { cp: 'vite.config.ts' },
'vite.config.ts': /* js */ `
import rsc from '@vitejs/plugin-rsc'
import react from '@vitejs/plugin-react'
import { defineConfig, mergeConfig } from 'vite'
import baseConfig from './vite.config.base.ts'
delete baseConfig.plugins
const overrideConfig = defineConfig({
plugins: [
react({ babel: { plugins: ['babel-plugin-react-compiler'] } }),
rsc(),
],
})
export default mergeConfig(baseConfig, overrideConfig)
`,
},
})
})
test.describe('dev-react-compiler', () => {
const f = useFixture({ root, mode: 'dev' })
defineStarterTest(f)
test('verify react compiler', async ({ page }) => {
await page.goto(f.url())
await waitForHydration(page)
const res = await page.request.get(f.url('src/client.tsx'))
expect(await res.text()).toContain('react.memo_cache_sentinel')
})
})
test.describe('build-react-compiler', () => {
const f = useFixture({ root, mode: 'build' })
defineStarterTest(f)
})
})