From 10bc9544ff2edbdce9b4e28d5f0e60295c16d5bc Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Tue, 22 Jul 2025 11:18:02 +0900 Subject: [PATCH 1/4] test(rsc): test "dev + NODE_ENV=production" and `build + NODE_ENV=development` --- packages/plugin-rsc/e2e/starter.test.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/packages/plugin-rsc/e2e/starter.test.ts b/packages/plugin-rsc/e2e/starter.test.ts index 8b1958471..88c267ba2 100644 --- a/packages/plugin-rsc/e2e/starter.test.ts +++ b/packages/plugin-rsc/e2e/starter.test.ts @@ -42,6 +42,28 @@ test.describe('build-no-ssr', () => { }) }) +test.describe('dev-production', () => { + const f = useFixture({ + root: 'examples/starter', + mode: 'dev', + cliOptions: { + env: { NODE_ENV: 'production' }, + }, + }) + defineTest(f) +}) + +test.describe('build-development', () => { + const f = useFixture({ + root: 'examples/starter', + mode: 'build', + cliOptions: { + env: { NODE_ENV: 'development' }, + }, + }) + defineTest(f) +}) + test.describe(() => { const root = 'examples/e2e/temp/react-compiler' From 4ef112b1063159fe7b072c634f8b6c67e47e08fd Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Tue, 22 Jul 2025 11:27:17 +0900 Subject: [PATCH 2/4] test: no client hmr on NODE_ENV=production --- packages/plugin-rsc/e2e/starter.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/plugin-rsc/e2e/starter.test.ts b/packages/plugin-rsc/e2e/starter.test.ts index 88c267ba2..2aad6d730 100644 --- a/packages/plugin-rsc/e2e/starter.test.ts +++ b/packages/plugin-rsc/e2e/starter.test.ts @@ -50,7 +50,7 @@ test.describe('dev-production', () => { env: { NODE_ENV: 'production' }, }, }) - defineTest(f) + defineTest(f, 'dev-production') }) test.describe('build-development', () => { @@ -225,7 +225,7 @@ test.describe(() => { }) }) -function defineTest(f: Fixture, variant?: 'no-ssr') { +function defineTest(f: Fixture, variant?: 'no-ssr' | 'dev-production') { const waitForHydration: typeof waitForHydration_ = (page) => waitForHydration_(page, variant === 'no-ssr' ? '#root' : 'body') @@ -264,7 +264,7 @@ function defineTest(f: Fixture, variant?: 'no-ssr') { }) test('client hmr', async ({ page }) => { - test.skip(f.mode === 'build') + test.skip(f.mode === 'build' || variant === 'dev-production') await page.goto(f.url()) await waitForHydration(page) From f764d7ce6e8c79adbc8d38beb3502c1bb0f79862 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Tue, 22 Jul 2025 11:35:36 +0900 Subject: [PATCH 3/4] test: verify --- packages/plugin-rsc/e2e/basic.test.ts | 8 +++++++- packages/plugin-rsc/e2e/starter.test.ts | 13 +++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/packages/plugin-rsc/e2e/basic.test.ts b/packages/plugin-rsc/e2e/basic.test.ts index 763cd379a..5a0464a09 100644 --- a/packages/plugin-rsc/e2e/basic.test.ts +++ b/packages/plugin-rsc/e2e/basic.test.ts @@ -2,7 +2,12 @@ import { createHash } from 'node:crypto' import { readFileSync } from 'node:fs' import { type Page, expect, test } from '@playwright/test' import { type Fixture, setupIsolatedFixture, useFixture } from './fixture' -import { expectNoReload, testNoJs, waitForHydration } from './helper' +import { + expectNoPageError, + expectNoReload, + testNoJs, + waitForHydration, +} from './helper' import path from 'node:path' import os from 'node:os' @@ -73,6 +78,7 @@ test.describe(() => { function defineTest(f: Fixture) { test('basic', async ({ page }) => { + using _ = expectNoPageError(page) await page.goto(f.url()) await waitForHydration(page) }) diff --git a/packages/plugin-rsc/e2e/starter.test.ts b/packages/plugin-rsc/e2e/starter.test.ts index 2aad6d730..2a0fd7ebd 100644 --- a/packages/plugin-rsc/e2e/starter.test.ts +++ b/packages/plugin-rsc/e2e/starter.test.ts @@ -1,6 +1,7 @@ import { expect, test } from '@playwright/test' import { setupInlineFixture, type Fixture, useFixture } from './fixture' import { + expectNoPageError, expectNoReload, testNoJs, waitForHydration as waitForHydration_, @@ -51,6 +52,13 @@ test.describe('dev-production', () => { }, }) defineTest(f, 'dev-production') + + test('verify production', 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()).not.toContain('jsxDev') + }) }) test.describe('build-development', () => { @@ -62,6 +70,10 @@ test.describe('build-development', () => { }, }) defineTest(f) + + test('verify development', async () => { + // TODO + }) }) test.describe(() => { @@ -230,6 +242,7 @@ function defineTest(f: Fixture, variant?: 'no-ssr' | 'dev-production') { waitForHydration_(page, variant === 'no-ssr' ? '#root' : 'body') test('basic', async ({ page }) => { + using _ = expectNoPageError(page) await page.goto(f.url()) await waitForHydration(page) }) From 253e0659366831cad5eaa0a826d1a400e2b92ca4 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Tue, 22 Jul 2025 12:05:41 +0900 Subject: [PATCH 4/4] test: verify development --- packages/plugin-rsc/e2e/starter.test.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/plugin-rsc/e2e/starter.test.ts b/packages/plugin-rsc/e2e/starter.test.ts index 2a0fd7ebd..ec5b3c42b 100644 --- a/packages/plugin-rsc/e2e/starter.test.ts +++ b/packages/plugin-rsc/e2e/starter.test.ts @@ -57,7 +57,7 @@ test.describe('dev-production', () => { await page.goto(f.url()) await waitForHydration_(page) const res = await page.request.get(f.url('src/client.tsx')) - expect(await res.text()).not.toContain('jsxDev') + expect(await res.text()).not.toContain('jsxDEV') }) }) @@ -71,8 +71,17 @@ test.describe('build-development', () => { }) defineTest(f) - test('verify development', async () => { - // TODO + test('verify development', async ({ page }) => { + let output!: string + page.on('response', async (response) => { + if (response.url().match(/\/assets\/client-[\w-]+\.js$/)) { + output = await response.text() + } + }) + await page.goto(f.url()) + await waitForHydration_(page) + console.log({ output }) + expect(output).toContain('jsxDEV') }) })