Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/plugin-rsc/e2e/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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)
})
Expand Down
48 changes: 46 additions & 2 deletions packages/plugin-rsc/e2e/starter.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { expect, test } from '@playwright/test'
import { setupInlineFixture, type Fixture, useFixture } from './fixture'
import {
expectNoPageError,
expectNoReload,
testNoJs,
waitForHydration as waitForHydration_,
Expand Down Expand Up @@ -42,6 +43,48 @@ test.describe('build-no-ssr', () => {
})
})

test.describe('dev-production', () => {
const f = useFixture({
root: 'examples/starter',
mode: 'dev',
cliOptions: {
env: { NODE_ENV: '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', () => {
const f = useFixture({
root: 'examples/starter',
mode: 'build',
cliOptions: {
env: { NODE_ENV: 'development' },
},
})
defineTest(f)

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')
})
})

test.describe(() => {
const root = 'examples/e2e/temp/react-compiler'

Expand Down Expand Up @@ -203,11 +246,12 @@ 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')

test('basic', async ({ page }) => {
using _ = expectNoPageError(page)
await page.goto(f.url())
await waitForHydration(page)
})
Expand Down Expand Up @@ -242,7 +286,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)
Expand Down
Loading