|
| 1 | +import { expect, test } from '@playwright/test' |
| 2 | +import { setupInlineFixture, useFixture } from './fixture' |
| 3 | +import { defineStarterTest } from './starter' |
| 4 | +import { waitForHydration } from './helper' |
| 5 | + |
| 6 | +test.describe(() => { |
| 7 | + const root = 'examples/e2e/temp/react-compiler' |
| 8 | + |
| 9 | + test.beforeAll(async () => { |
| 10 | + await setupInlineFixture({ |
| 11 | + src: 'examples/starter', |
| 12 | + dest: root, |
| 13 | + files: { |
| 14 | + 'vite.config.base.ts': { cp: 'vite.config.ts' }, |
| 15 | + 'vite.config.ts': /* js */ ` |
| 16 | + import rsc from '@vitejs/plugin-rsc' |
| 17 | + import react from '@vitejs/plugin-react' |
| 18 | + import { defineConfig, mergeConfig } from 'vite' |
| 19 | + import baseConfig from './vite.config.base.ts' |
| 20 | + |
| 21 | + delete baseConfig.plugins |
| 22 | +
|
| 23 | + const overrideConfig = defineConfig({ |
| 24 | + plugins: [ |
| 25 | + react({ |
| 26 | + babel: { plugins: ['babel-plugin-react-compiler'] }, |
| 27 | + }).map((p) => ({ |
| 28 | + ...p, |
| 29 | + applyToEnvironment: (e) => e.name === 'client', |
| 30 | + })), |
| 31 | + rsc(), |
| 32 | + ], |
| 33 | + }) |
| 34 | +
|
| 35 | + export default mergeConfig(baseConfig, overrideConfig) |
| 36 | + `, |
| 37 | + }, |
| 38 | + }) |
| 39 | + }) |
| 40 | + |
| 41 | + test.describe('dev-react-compiler', () => { |
| 42 | + const f = useFixture({ root, mode: 'dev' }) |
| 43 | + defineStarterTest(f) |
| 44 | + |
| 45 | + test('verify react compiler', async ({ page }) => { |
| 46 | + await page.goto(f.url()) |
| 47 | + await waitForHydration(page) |
| 48 | + const res = await page.request.get(f.url('src/client.tsx')) |
| 49 | + expect(await res.text()).toContain('react.memo_cache_sentinel') |
| 50 | + }) |
| 51 | + }) |
| 52 | + |
| 53 | + test.describe('build-react-compiler', () => { |
| 54 | + const f = useFixture({ root, mode: 'build' }) |
| 55 | + defineStarterTest(f) |
| 56 | + }) |
| 57 | +}) |
0 commit comments