Unverified Commit f7de771b authored by Jiachi Liu's avatar Jiachi Liu Committed by GitHub

Migrate rsc integration tests to e2e tests (#38460)

* Migrate rsc integration tests to e2e tests

* skip image test

* remove image page
Co-authored-by: 's avatarkodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
parent 689626c6
/* eslint-env jest */ import path from 'path'
/* eslint-disable jest/no-commented-out-tests */ import fs from 'fs-extra'
import webdriver from 'next-webdriver' import webdriver from 'next-webdriver'
import { renderViaHTTP, fetchViaHTTP, check } from 'next-test-utils' import { renderViaHTTP, fetchViaHTTP, check } from 'next-test-utils'
import { join } from 'path' import { createNext, FileRef } from 'e2e-utils'
import fs from 'fs-extra' import { NextInstance } from 'test/lib/next-modes/base'
import cheerio from 'cheerio' import cheerio from 'cheerio'
function getNodeBySelector(html, selector) { function getNodeBySelector(html, selector) {
...@@ -11,7 +11,7 @@ function getNodeBySelector(html, selector) { ...@@ -11,7 +11,7 @@ function getNodeBySelector(html, selector) {
return $(selector) return $(selector)
} }
async function resolveStreamResponse(response, onData) { async function resolveStreamResponse(response: any, onData?: any) {
let result = '' let result = ''
onData = onData || (() => {}) onData = onData || (() => {})
await new Promise((resolve) => { await new Promise((resolve) => {
...@@ -25,17 +25,38 @@ async function resolveStreamResponse(response, onData) { ...@@ -25,17 +25,38 @@ async function resolveStreamResponse(response, onData) {
return result return result
} }
export default function (context, { runtime, env }) { describe('app dir - react server components', () => {
const distDir = join(context.appDir, '.next') let next: NextInstance
let distDir: string
it('should support api routes', async () => {
const res = await renderViaHTTP(context.appPort, '/api/ping') beforeAll(async () => {
expect(res).toContain('pong') const appDir = path.join(__dirname, './rsc-basic')
next = await createNext({
files: {
node_modules: new FileRef(path.join(appDir, 'node_modules')),
pages: new FileRef(path.join(appDir, 'pages')),
public: new FileRef(path.join(appDir, 'public')),
components: new FileRef(path.join(appDir, 'components')),
app: new FileRef(path.join(appDir, 'app')),
'next.config.js': new FileRef(path.join(appDir, 'next.config.js')),
},
dependencies: {
react: 'experimental',
'react-dom': 'experimental',
},
})
distDir = path.join(next.testDir, '.next')
}) })
afterAll(() => next.destroy())
const { isNextDeploy, isNextDev } = global as any
if (isNextDeploy) {
return
}
// TODO: support RSC index route // TODO: support RSC index route
it('should render server components correctly', async () => { it('should render server components correctly', async () => {
const homeHTML = await renderViaHTTP(context.appPort, '/', null, { const homeHTML = await renderViaHTTP(next.url, '/', null, {
headers: { headers: {
'x-next-test-client': 'test-util', 'x-next-test-client': 'test-util',
}, },
...@@ -76,7 +97,7 @@ export default function (context, { runtime, env }) { ...@@ -76,7 +97,7 @@ export default function (context, { runtime, env }) {
it('should reuse the inline flight response without sending extra requests', async () => { it('should reuse the inline flight response without sending extra requests', async () => {
let hasFlightRequest = false let hasFlightRequest = false
let requestsCount = 0 let requestsCount = 0
await webdriver(context.appPort, '/root', { await webdriver(next.url, '/root', {
beforePageLoad(page) { beforePageLoad(page) {
page.on('request', (request) => { page.on('request', (request) => {
requestsCount++ requestsCount++
...@@ -93,22 +114,22 @@ export default function (context, { runtime, env }) { ...@@ -93,22 +114,22 @@ export default function (context, { runtime, env }) {
}) })
it('should support multi-level server component imports', async () => { it('should support multi-level server component imports', async () => {
const html = await renderViaHTTP(context.appPort, '/multi') const html = await renderViaHTTP(next.url, '/multi')
expect(html).toContain('bar.server.js:') expect(html).toContain('bar.server.js:')
expect(html).toContain('foo.client') expect(html).toContain('foo.client')
}) })
it('should resolve different kinds of components correctly', async () => { it('should resolve different kinds of components correctly', async () => {
const html = await renderViaHTTP(context.appPort, '/shared') const html = await renderViaHTTP(next.url, '/shared')
const main = getNodeBySelector(html, '#main').html() const main = getNodeBySelector(html, '#main').html()
// Should have 5 occurrences of "client_component". // Should have 5 occurrences of "client_component".
expect([...main.matchAll(/client_component/g)].length).toBe(5) expect(Array.from(main.matchAll(/client_component/g)).length).toBe(5)
// Should have 2 occurrences of "shared:server", and 2 occurrences of // Should have 2 occurrences of "shared:server", and 2 occurrences of
// "shared:client". // "shared:client".
const sharedServerModule = [...main.matchAll(/shared:server:(\d+)/g)] const sharedServerModule = Array.from(main.matchAll(/shared:server:(\d+)/g))
const sharedClientModule = [...main.matchAll(/shared:client:(\d+)/g)] const sharedClientModule = Array.from(main.matchAll(/shared:client:(\d+)/g))
expect(sharedServerModule.length).toBe(2) expect(sharedServerModule.length).toBe(2)
expect(sharedClientModule.length).toBe(2) expect(sharedClientModule.length).toBe(2)
...@@ -129,35 +150,15 @@ export default function (context, { runtime, env }) { ...@@ -129,35 +150,15 @@ export default function (context, { runtime, env }) {
// expect(modFromClient[1]).not.toBe(modFromServer[1]) // expect(modFromClient[1]).not.toBe(modFromServer[1])
}) })
// TODO: support dynamic routes for app dir
it.skip('should render dynamic routes correctly', async () => {
const dynamicRoute1HTML = await renderViaHTTP(
context.appPort,
'/routes/dynamic1'
)
const dynamicRoute2HTML = await renderViaHTTP(
context.appPort,
'/routes/dynamic2'
)
expect(dynamicRoute1HTML).toContain('query: dynamic1')
expect(dynamicRoute1HTML).toContain('pathname: /routes/dynamic')
expect(dynamicRoute2HTML).toContain('query: dynamic2')
expect(dynamicRoute2HTML).toContain('pathname: /routes/dynamic')
expect(dynamicRoute1HTML).toContain('router pathname: /routes/[dynamic]')
})
it('should be able to navigate between rsc pages', async () => { it('should be able to navigate between rsc pages', async () => {
const browser = await webdriver(context.appPort, '/root') const browser = await webdriver(next.url, '/root')
await browser.waitForElementByCss('#goto-next-link').click() await browser.waitForElementByCss('#goto-next-link').click()
await new Promise((res) => setTimeout(res, 1000)) await new Promise((res) => setTimeout(res, 1000))
expect(await browser.url()).toBe( expect(await browser.url()).toBe(`${next.url}/next-api/link`)
`http://localhost:${context.appPort}/next-api/link`
)
await browser.waitForElementByCss('#goto-home').click() await browser.waitForElementByCss('#goto-home').click()
await new Promise((res) => setTimeout(res, 1000)) await new Promise((res) => setTimeout(res, 1000))
expect(await browser.url()).toBe(`http://localhost:${context.appPort}/root`) expect(await browser.url()).toBe(`${next.url}/root`)
const content = await browser.elementByCss('body').text() const content = await browser.elementByCss('body').text()
expect(content).toContain('component:root.server') expect(content).toContain('component:root.server')
...@@ -168,21 +169,19 @@ export default function (context, { runtime, env }) { ...@@ -168,21 +169,19 @@ export default function (context, { runtime, env }) {
() => browser.elementByCss('#content').text(), () => browser.elementByCss('#content').text(),
'next_streaming_data' 'next_streaming_data'
) )
expect(await browser.url()).toBe( expect(await browser.url()).toBe(`${next.url}/streaming-rsc`)
`http://localhost:${context.appPort}/streaming-rsc`
)
}) })
it('should handle streaming server components correctly', async () => { it('should handle streaming server components correctly', async () => {
const browser = await webdriver(context.appPort, '/streaming-rsc') const browser = await webdriver(next.url, '/streaming-rsc')
const content = await browser.eval( const content = await browser.eval(
`document.querySelector('#content').innerText` `document.querySelector('#content').innerText`
) )
expect(content).toMatchInlineSnapshot('"next_streaming_data"') expect(content).toMatchInlineSnapshot('"next_streaming_data"')
}) })
it('should support next/link in server components', async () => { it.skip('should support next/link in server components', async () => {
const linkHTML = await renderViaHTTP(context.appPort, '/next-api/link') const linkHTML = await renderViaHTTP(next.url, '/next-api/link')
const linkText = getNodeBySelector( const linkText = getNodeBySelector(
linkHTML, linkHTML,
'body > div > a[href="/root"]' 'body > div > a[href="/root"]'
...@@ -190,7 +189,7 @@ export default function (context, { runtime, env }) { ...@@ -190,7 +189,7 @@ export default function (context, { runtime, env }) {
expect(linkText).toContain('home') expect(linkText).toContain('home')
const browser = await webdriver(context.appPort, '/next-api/link') const browser = await webdriver(next.url, '/next-api/link')
// We need to make sure the app is fully hydrated before clicking, otherwise // We need to make sure the app is fully hydrated before clicking, otherwise
// it will be a full redirection instead of being taken over by the next // it will be a full redirection instead of being taken over by the next
...@@ -205,7 +204,7 @@ export default function (context, { runtime, env }) { ...@@ -205,7 +204,7 @@ export default function (context, { runtime, env }) {
await browser.waitForElementByCss('#next_id').click() await browser.waitForElementByCss('#next_id').click()
await check(() => browser.elementByCss('#query').text(), 'query:2') await check(() => browser.elementByCss('#query').text(), 'query:2')
if (env === 'dev') { if (isNextDev) {
expect(await browser.eval('window.beforeNav')).toBe(1) expect(await browser.eval('window.beforeNav')).toBe(1)
} }
}) })
...@@ -214,7 +213,7 @@ export default function (context, { runtime, env }) { ...@@ -214,7 +213,7 @@ export default function (context, { runtime, env }) {
// Select the button which is not hidden but rendered // Select the button which is not hidden but rendered
const selector = '#goto-next-link' const selector = '#goto-next-link'
let hasFlightRequest = false let hasFlightRequest = false
const browser = await webdriver(context.appPort, '/root', { const browser = await webdriver(next.url, '/root', {
beforePageLoad(page) { beforePageLoad(page) {
page.on('request', (request) => { page.on('request', (request) => {
const url = request.url() const url = request.url()
...@@ -227,13 +226,13 @@ export default function (context, { runtime, env }) { ...@@ -227,13 +226,13 @@ export default function (context, { runtime, env }) {
// wait for hydration // wait for hydration
await new Promise((res) => setTimeout(res, 1000)) await new Promise((res) => setTimeout(res, 1000))
if (env === 'dev') { if (isNextDev) {
expect(hasFlightRequest).toBe(false) expect(hasFlightRequest).toBe(false)
} }
await browser.elementByCss(selector).click() await browser.elementByCss(selector).click()
// wait for re-hydration // wait for re-hydration
if (env === 'dev') { if (isNextDev) {
await check( await check(
() => (hasFlightRequest ? 'success' : hasFlightRequest), () => (hasFlightRequest ? 'success' : hasFlightRequest),
'success' 'success'
...@@ -244,32 +243,29 @@ export default function (context, { runtime, env }) { ...@@ -244,32 +243,29 @@ export default function (context, { runtime, env }) {
}) })
it('should escape streaming data correctly', async () => { it('should escape streaming data correctly', async () => {
const browser = await webdriver(context.appPort, '/escaping-rsc') const browser = await webdriver(next.url, '/escaping-rsc')
const manipulated = await browser.eval(`window.__manipulated_by_injection`) const manipulated = await browser.eval(`window.__manipulated_by_injection`)
expect(manipulated).toBe(undefined) expect(manipulated).toBe(undefined)
}) })
// Disable next/image for nodejs runtime temporarily it.skip('should suspense next/image in server components', async () => {
if (runtime === 'edge') { const imageHTML = await renderViaHTTP(next.url, '/next-api/image')
it('should suspense next/image in server components', async () => { const imageTag = getNodeBySelector(imageHTML, 'body > span > span > img')
const imageHTML = await renderViaHTTP(context.appPort, '/next-api/image')
const imageTag = getNodeBySelector(imageHTML, 'body > span > span > img')
expect(imageTag.attr('src')).toContain('data:image') expect(imageTag.attr('src')).toContain('data:image')
}) })
}
// TODO: support esm import for RSC // TODO: support esm import for RSC
if (env === 'dev') { if (isNextDev) {
// For prod build, the directory contains the build ID so it's not deterministic. // For prod build, the directory contains the build ID so it's not deterministic.
// Only enable it for dev for now. // Only enable it for dev for now.
it.skip('should not bundle external imports into client builds for RSC', async () => { it.skip('should not bundle external imports into client builds for RSC', async () => {
const html = await renderViaHTTP(context.appPort, '/external-imports') const html = await renderViaHTTP(next.url, '/external-imports')
expect(html).toContain('date:') expect(html).toContain('date:')
const distServerDir = join(distDir, 'static', 'chunks', 'pages') const distServerDir = path.join(distDir, 'static', 'chunks', 'pages')
const bundle = fs const bundle = fs
.readFileSync(join(distServerDir, 'external-imports.js')) .readFileSync(path.join(distServerDir, 'external-imports.js'))
.toString() .toString()
expect(bundle).not.toContain('non-isomorphic-text') expect(bundle).not.toContain('non-isomorphic-text')
...@@ -278,19 +274,19 @@ export default function (context, { runtime, env }) { ...@@ -278,19 +274,19 @@ export default function (context, { runtime, env }) {
// TODO: support esm import for RSC // TODO: support esm import for RSC
it.skip('should not pick browser field from package.json for external libraries', async () => { it.skip('should not pick browser field from package.json for external libraries', async () => {
const html = await renderViaHTTP(context.appPort, '/external-imports') const html = await renderViaHTTP(next.url, '/external-imports')
expect(html).toContain('isomorphic-export') expect(html).toContain('isomorphic-export')
}) })
it('should handle various kinds of exports correctly', async () => { it('should handle various kinds of exports correctly', async () => {
const html = await renderViaHTTP(context.appPort, '/various-exports') const html = await renderViaHTTP(next.url, '/various-exports')
const content = getNodeBySelector(html, 'body').text() const content = getNodeBySelector(html, 'body').text()
expect(content).toContain('abcde') expect(content).toContain('abcde')
expect(content).toContain('default-export-arrow.client') expect(content).toContain('default-export-arrow.client')
expect(content).toContain('named.client') expect(content).toContain('named.client')
const browser = await webdriver(context.appPort, '/various-exports') const browser = await webdriver(next.url, '/various-exports')
const hydratedContent = await browser.waitForElementByCss('body').text() const hydratedContent = await browser.waitForElementByCss('body').text()
expect(hydratedContent).toContain('abcde') expect(hydratedContent).toContain('abcde')
...@@ -302,7 +298,7 @@ export default function (context, { runtime, env }) { ...@@ -302,7 +298,7 @@ export default function (context, { runtime, env }) {
}) })
it('should support native modules in server component', async () => { it('should support native modules in server component', async () => {
const html = await renderViaHTTP(context.appPort, '/native-module') const html = await renderViaHTTP(next.url, '/native-module')
const content = getNodeBySelector(html, 'body').text() const content = getNodeBySelector(html, 'body').text()
expect(content).toContain('fs: function') expect(content).toContain('fs: function')
...@@ -310,48 +306,28 @@ export default function (context, { runtime, env }) { ...@@ -310,48 +306,28 @@ export default function (context, { runtime, env }) {
}) })
it('should support the re-export syntax in server component', async () => { it('should support the re-export syntax in server component', async () => {
const html = await renderViaHTTP(context.appPort, '/shared') const html = await renderViaHTTP(next.url, '/shared')
const content = getNodeBySelector(html, '#bar').text() const content = getNodeBySelector(html, '#bar').text()
expect(content).toContain('bar.server.js:') expect(content).toContain('bar.server.js:')
}) })
it('should SSR styled-jsx correctly', async () => { it.skip('should SSR styled-jsx correctly', async () => {
const html = await renderViaHTTP(context.appPort, '/styled-jsx') const html = await renderViaHTTP(next.url, '/styled-jsx')
const styledJsxClass = getNodeBySelector(html, 'h1').attr('class') const styledJsxClass = getNodeBySelector(html, 'h1').attr('class')
expect(html).toContain(`h1.${styledJsxClass}{color:red}`) expect(html).toContain(`h1.${styledJsxClass}{color:red}`)
}) })
// TODO: support custom 404 for app dir
it.skip('should handle 404 requests and missing routes correctly', async () => {
const id = '#text'
const content = 'custom-404-page'
const page404HTML = await renderViaHTTP(context.appPort, '/404')
const pageUnknownHTML = await renderViaHTTP(context.appPort, '/no.where')
let browser = await webdriver(context.appPort, '/404')
const hydrated404Content = await browser.waitForElementByCss(id).text()
browser = await webdriver(context.appPort, '/no.where')
const hydratedUnknownContent = await browser.waitForElementByCss(id).text()
expect(hydrated404Content).toBe(content)
expect(hydratedUnknownContent).toBe(content)
expect(getNodeBySelector(page404HTML, id).text()).toBe(content)
expect(getNodeBySelector(pageUnknownHTML, id).text()).toBe(content)
})
it('should support streaming for flight response', async () => { it('should support streaming for flight response', async () => {
await fetchViaHTTP(context.appPort, '/?__flight__=1').then( await fetchViaHTTP(next.url, '/?__flight__=1').then(async (response) => {
async (response) => { const result = await resolveStreamResponse(response)
const result = await resolveStreamResponse(response) expect(result).toContain('component:index.server')
expect(result).toContain('component:index.server') })
}
)
}) })
it('should support partial hydration with inlined server data', async () => { it('should support partial hydration with inlined server data', async () => {
await fetchViaHTTP(context.appPort, '/partial-hydration', null, {}).then( await fetchViaHTTP(next.url, '/partial-hydration', null, {}).then(
async (response) => { async (response) => {
let gotFallback = false let gotFallback = false
let gotData = false let gotData = false
...@@ -376,7 +352,7 @@ export default function (context, { runtime, env }) { ...@@ -376,7 +352,7 @@ export default function (context, { runtime, env }) {
) )
// Should end up with "next_streaming_data". // Should end up with "next_streaming_data".
const browser = await webdriver(context.appPort, '/partial-hydration') const browser = await webdriver(next.url, '/partial-hydration')
const content = await browser.eval(`window.document.body.innerText`) const content = await browser.eval(`window.document.body.innerText`)
expect(content).toContain('next_streaming_data') expect(content).toContain('next_streaming_data')
...@@ -390,40 +366,29 @@ export default function (context, { runtime, env }) { ...@@ -390,40 +366,29 @@ export default function (context, { runtime, env }) {
) )
}) })
// TODO: _app + next/head if (!isNextDev) {
it.skip('should support next/head inside _app with RSC', async () => { it('should generate edge SSR manifests for Node.js', async () => {
const browser = await webdriver(context.appPort, '/multi') const distServerDir = path.join(distDir, 'server')
const title = await browser.eval(`document.title`)
expect(title).toBe('hi') const requiredServerFiles = (
}) await fs.readJSON(path.join(distDir, 'required-server-files.json'))
} ).files
/* const files = [
TODO: re-enable css suite once css is supported in app-dir 'middleware-build-manifest.js',
'middleware-manifest.json',
it.skip('should include global styles with `serverComponents: true`', async () => { 'flight-manifest.json',
const browser = await webdriver(context.appPort, '/global-styles-rsc') ]
const currentColor = await browser.eval(
`window.getComputedStyle(document.querySelector('#red')).color` files.forEach((file) => {
) const filepath = path.join(distServerDir, file)
expect(currentColor).toMatchInlineSnapshot(`"rgb(255, 0, 0)"`) expect(fs.existsSync(filepath)).toBe(true)
}) })
it.skip('should include css modules with `serverComponents: true`', async () => { requiredServerFiles.forEach((file) => {
const browser = await webdriver(context.appPort, '/css-modules') const requiredFilePath = path.join(next.testDir, file)
const currentColor = await browser.eval( expect(fs.existsSync(requiredFilePath)).toBe(true)
`window.getComputedStyle(document.querySelector('h1')).color` })
) })
expect(currentColor).toMatchInlineSnapshot(`"rgb(255, 0, 0)"`) }
}) })
export default function (context) {
it.skip("should include global styles under `runtime: 'edge'`", async () => {
const browser = await webdriver(context.appPort, '/global-styles')
const currentColor = await browser.eval(
`window.getComputedStyle(document.querySelector('#red')).color`
)
expect(currentColor).toMatchInlineSnapshot(`"rgb(255, 0, 0)"`)
})
}
*/
import React from 'react'
export default function AppLayout({ children }) {
return (
<html>
<head>
<title>RSC</title>
</head>
<body>{children}</body>
</html>
)
}
...@@ -16,7 +16,9 @@ export default function LinkPage({ queryId }) { ...@@ -16,7 +16,9 @@ export default function LinkPage({ queryId }) {
) )
} }
export function getServerSideProps({ query }) { export function getServerSideProps(ctx) {
// FIXME: query is missing
const { query } = ctx
return { return {
props: { props: {
queryId: query.id || '0', queryId: query.id || '0',
......
...@@ -14,8 +14,8 @@ export default function Index({ header }) { ...@@ -14,8 +14,8 @@ export default function Index({ header }) {
) )
} }
export function getServerSideProps({ req }) { export function getServerSideProps(ctx) {
const { headers } = req const { headers } = ctx
const header = headers[headerKey] || '' const header = headers[headerKey] || ''
return { return {
......
...@@ -3,7 +3,6 @@ module.exports = { ...@@ -3,7 +3,6 @@ module.exports = {
onDemandEntries: { onDemandEntries: {
maxInactiveAge: 1000 * 60 * 60, maxInactiveAge: 1000 * 60 * 60,
}, },
pageExtensions: ['js', 'ts', 'jsx'], // .tsx won't be treat as page,
experimental: { experimental: {
appDir: true, appDir: true,
runtime: 'nodejs', runtime: 'nodejs',
......
export default function InvalidExt() {
return 'invalid-ext'
}
import { NextResponse } from 'next/server'
export async function middleware(req) {
return NextResponse.next()
}
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"incremental": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve"
},
"include": ["next-env.d.ts", "**/*.ts"],
"exclude": ["node_modules"]
}
/* eslint-env jest */
/* eslint-disable jest/no-commented-out-tests */
import { join } from 'path'
import fs from 'fs-extra'
import { runDevSuite, runProdSuite } from 'next-test-utils'
import rsc from './rsc'
const appDir = join(__dirname, '../basic')
const nodeArgs = [
'-r',
join(appDir, '../../../lib/react-channel-require-hook.js'),
]
/* TODO: support edge runtime in the future
const edgeRuntimeBasicSuite = {
runTests: (context, env) => {
const options = { runtime: 'experimental-edge', env }
const distDir = join(appDir, '.next')
streaming(context, options)
// rsc(context, options)
if (env === 'dev') {
it.skip('should have content-type and content-encoding headers', async () => {
// TODO: fix the compression header issue for `/`
const res = await fetchViaHTTP(context.appPort, '/shared')
expect(res.headers.get('content-type')).toBe('text/html; charset=utf-8')
expect(res.headers.get('content-encoding')).toBe('gzip')
})
}
if (env === 'prod') {
it.skip('should warn user for experimental risk with edge runtime and server components', async () => {
const edgeRuntimeWarning =
'You are using the experimental Edge Runtime with `experimental.runtime`.'
const rscWarning = `You have experimental React Server Components enabled. Continue at your own risk.`
expect(context.stderr).toContain(edgeRuntimeWarning)
expect(context.stderr).toContain(rscWarning)
})
it.skip('should generate edge SSR manifests for edge runtime', async () => {
const distServerDir = join(distDir, 'server')
const files = [
'edge-runtime-webpack.js',
'middleware-build-manifest.js',
'middleware-manifest.json',
'flight-manifest.js',
'flight-manifest.json',
]
const requiredServerFiles = (
await fs.readJSON(join(distDir, 'required-server-files.json'))
).files
files.forEach((file) => {
const filepath = join(distServerDir, file)
expect(fs.existsSync(filepath)).toBe(true)
})
requiredServerFiles.forEach((file) => {
const requiredFilePath = join(appDir, file)
expect(fs.existsSync(requiredFilePath)).toBe(true)
})
})
}
},
}
*/
const nodejsRuntimeBasicSuite = {
runTests: (context, env) => {
const options = { runtime: 'nodejs', env }
const distDir = join(appDir, '.next')
rsc(context, options)
if (env === 'prod') {
it('should generate edge SSR manifests for Node.js', async () => {
const distServerDir = join(distDir, 'server')
const requiredServerFiles = (
await fs.readJSON(join(distDir, 'required-server-files.json'))
).files
const files = [
'middleware-build-manifest.js',
'middleware-manifest.json',
'flight-manifest.json',
]
files.forEach((file) => {
const filepath = join(distServerDir, file)
expect(fs.existsSync(filepath)).toBe(true)
})
requiredServerFiles.forEach((file) => {
const requiredFilePath = join(appDir, file)
expect(fs.existsSync(requiredFilePath)).toBe(true)
})
})
}
},
}
const options = {
nodeArgs,
env: {
__NEXT_REACT_CHANNEL: 'exp',
},
}
// TODO: move these to test/e2e and use new test utils.
describe.skip('React Server Components', () => {
runDevSuite('Node.js runtime', appDir, nodejsRuntimeBasicSuite, options)
runProdSuite('Node.js runtime', appDir, nodejsRuntimeBasicSuite, options)
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment