|
1 | 1 | import { expect, test } from '@playwright/test'
|
2 | 2 | import { setupInlineFixture, type Fixture, useFixture } from './fixture'
|
3 | 3 | import {
|
| 4 | + expectNoPageError, |
4 | 5 | expectNoReload,
|
5 | 6 | testNoJs,
|
6 | 7 | waitForHydration as waitForHydration_,
|
@@ -42,6 +43,48 @@ test.describe('build-no-ssr', () => {
|
42 | 43 | })
|
43 | 44 | })
|
44 | 45 |
|
| 46 | +test.describe('dev-production', () => { |
| 47 | + const f = useFixture({ |
| 48 | + root: 'examples/starter', |
| 49 | + mode: 'dev', |
| 50 | + cliOptions: { |
| 51 | + env: { NODE_ENV: 'production' }, |
| 52 | + }, |
| 53 | + }) |
| 54 | + defineTest(f, 'dev-production') |
| 55 | + |
| 56 | + test('verify production', async ({ page }) => { |
| 57 | + await page.goto(f.url()) |
| 58 | + await waitForHydration_(page) |
| 59 | + const res = await page.request.get(f.url('src/client.tsx')) |
| 60 | + expect(await res.text()).not.toContain('jsxDEV') |
| 61 | + }) |
| 62 | +}) |
| 63 | + |
| 64 | +test.describe('build-development', () => { |
| 65 | + const f = useFixture({ |
| 66 | + root: 'examples/starter', |
| 67 | + mode: 'build', |
| 68 | + cliOptions: { |
| 69 | + env: { NODE_ENV: 'development' }, |
| 70 | + }, |
| 71 | + }) |
| 72 | + defineTest(f) |
| 73 | + |
| 74 | + test('verify development', async ({ page }) => { |
| 75 | + let output!: string |
| 76 | + page.on('response', async (response) => { |
| 77 | + if (response.url().match(/\/assets\/client-[\w-]+\.js$/)) { |
| 78 | + output = await response.text() |
| 79 | + } |
| 80 | + }) |
| 81 | + await page.goto(f.url()) |
| 82 | + await waitForHydration_(page) |
| 83 | + console.log({ output }) |
| 84 | + expect(output).toContain('jsxDEV') |
| 85 | + }) |
| 86 | +}) |
| 87 | + |
45 | 88 | test.describe(() => {
|
46 | 89 | const root = 'examples/e2e/temp/react-compiler'
|
47 | 90 |
|
@@ -203,11 +246,12 @@ test.describe(() => {
|
203 | 246 | })
|
204 | 247 | })
|
205 | 248 |
|
206 |
| -function defineTest(f: Fixture, variant?: 'no-ssr') { |
| 249 | +function defineTest(f: Fixture, variant?: 'no-ssr' | 'dev-production') { |
207 | 250 | const waitForHydration: typeof waitForHydration_ = (page) =>
|
208 | 251 | waitForHydration_(page, variant === 'no-ssr' ? '#root' : 'body')
|
209 | 252 |
|
210 | 253 | test('basic', async ({ page }) => {
|
| 254 | + using _ = expectNoPageError(page) |
211 | 255 | await page.goto(f.url())
|
212 | 256 | await waitForHydration(page)
|
213 | 257 | })
|
@@ -242,7 +286,7 @@ function defineTest(f: Fixture, variant?: 'no-ssr') {
|
242 | 286 | })
|
243 | 287 |
|
244 | 288 | test('client hmr', async ({ page }) => {
|
245 |
| - test.skip(f.mode === 'build') |
| 289 | + test.skip(f.mode === 'build' || variant === 'dev-production') |
246 | 290 |
|
247 | 291 | await page.goto(f.url())
|
248 | 292 | await waitForHydration(page)
|
|
0 commit comments