first commit
Some checks failed
Test examples / Test Examples (20) (push) Has been cancelled
Test examples / Test Examples (22) (push) Has been cancelled
Lock Threads / action (push) Has been cancelled
Trigger Release / start (push) Has been cancelled
Stale issue handler / stale (push) Has been cancelled
Update Font Data / create-pull-request (push) Has been cancelled
build-and-deploy / deploy-target (push) Has been cancelled
build-and-deploy / build (push) Has been cancelled
build-and-deploy / stable - aarch64-unknown-linux-musl - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-unknown-linux-musl - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-unknown-linux-gnu - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-unknown-linux-gnu - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-pc-windows-msvc - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-pc-windows-msvc - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-apple-darwin - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-apple-darwin - node@16 (push) Has been cancelled
build-and-deploy / build-wasm (nodejs) (push) Has been cancelled
build-and-deploy / build-wasm (web) (push) Has been cancelled
build-and-deploy / Deploy preview tarball (push) Has been cancelled
build-and-deploy / Potentially publish release (push) Has been cancelled
build-and-deploy / publish-turbopack-npm-packages (push) Has been cancelled
build-and-deploy / Deploy examples (push) Has been cancelled
build-and-deploy / thank you, build (push) Has been cancelled
build-and-deploy / Upload Turbopack Bytesize metrics to Datadog (push) Has been cancelled
Rspack Next.js development integration tests / Rspack integration tests (push) Has been cancelled
Rspack Next.js production integration tests / Rspack integration tests (push) Has been cancelled
Turbopack Next.js development integration tests / Next.js integration tests (push) Has been cancelled
Turbopack Next.js production integration tests / Next.js integration tests (push) Has been cancelled
Update Rspack test manifest / Update and upload Rspack development test manifest (push) Has been cancelled
Update Rspack test manifest / Update and upload Rspack production test manifest (push) Has been cancelled
Upload bundler test manifests to areweturboyet.com / Upload test results (push) Has been cancelled
Update React / create-pull-request (push) Has been cancelled
test-e2e-project-reset-cron / reset-test-project (push) Has been cancelled
Notify about the top 15 issues/PRs/feature requests (most reacted) in the last 90 days / run (push) Has been cancelled

This commit is contained in:
Arian Tron
2026-03-10 19:37:31 +03:30
commit 61f56f997c
27684 changed files with 2784175 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
/* eslint-env jest */
import { nextTestSetup } from 'e2e-utils'
describe('Async modules', () => {
const { next, isNextDev: dev } = nextTestSetup({
files: __dirname,
})
it('ssr async page modules', async () => {
const $ = await next.render$('/')
expect($('#app-value').text()).toBe('hello')
expect($('#page-value').text()).toBe('42')
})
it('csr async page modules', async () => {
const browser = await next.browser('/')
expect(await browser.elementByCss('#app-value').text()).toBe('hello')
expect(await browser.elementByCss('#page-value').text()).toBe('42')
expect(await browser.elementByCss('#doc-value').text()).toBe('doc value')
})
it('works on async api routes', async () => {
const res = await next.fetch('/api/hello')
expect(res.status).toBe(200)
const result = await res.json()
expect(result).toHaveProperty('value', 42)
})
it('works with getServerSideProps', async () => {
const browser = await next.browser('/gssp')
expect(await browser.elementByCss('#gssp-value').text()).toBe('42')
})
it('works with getStaticProps', async () => {
const browser = await next.browser('/gsp')
expect(await browser.elementByCss('#gsp-value').text()).toBe('42')
})
it('can render async 404 pages', async () => {
const browser = await next.browser('/dhiuhefoiahjeoij')
expect(await browser.elementByCss('#content-404').text()).toBe("hi y'all")
})
;(dev ? it.skip : it)('can render async error page', async () => {
const browser = await next.browser('/make-error')
// eslint-disable-next-line jest/no-standalone-expect
expect(await browser.elementByCss('#content-error').text()).toBe(
'hello error'
)
})
})

View File

@@ -0,0 +1 @@
module.exports = {}

View File

@@ -0,0 +1,5 @@
const content = await Promise.resolve("hi y'all")
export default function Custom404() {
return <h1 id="content-404">{content}</h1>
}

View File

@@ -0,0 +1,5 @@
const appValue = await Promise.resolve('hello')
export default function MyApp({ Component, pageProps }) {
return <Component {...pageProps} appValue={appValue} />
}

View File

@@ -0,0 +1,25 @@
import Document, { Html, Head, Main, NextScript } from 'next/document'
const docValue = await Promise.resolve('doc value')
class MyDocument extends Document {
static async getInitialProps(ctx) {
const initialProps = await Document.getInitialProps(ctx)
return { ...initialProps, docValue }
}
render() {
return (
<Html>
<Head />
<body>
<div id="doc-value">{this.props.docValue}</div>
<Main />
<NextScript />
</body>
</Html>
)
}
}
export default MyDocument

View File

@@ -0,0 +1,7 @@
const errorContent = await Promise.resolve('hello error')
function Error({ statusCode }) {
return <p id="content-error">{errorContent}</p>
}
export default Error

View File

@@ -0,0 +1,5 @@
const value = await Promise.resolve(42)
export default function (req, res) {
res.json({ value })
}

View File

@@ -0,0 +1,10 @@
await Promise.resolve('tadaa')
export default function Config() {
const date = new Date()
return (
<div>
<p>Config page loaded at: {date.toJSON()}</p>
</div>
)
}

View File

@@ -0,0 +1,15 @@
const gspValue = await Promise.resolve(42)
export async function getStaticProps() {
return {
props: { gspValue },
}
}
export default function Index({ gspValue }) {
return (
<main>
<div id="gsp-value">{gspValue}</div>
</main>
)
}

View File

@@ -0,0 +1,15 @@
const gsspValue = await Promise.resolve(42)
export async function getServerSideProps() {
return {
props: { gsspValue },
}
}
export default function Index({ gsspValue }) {
return (
<main>
<div id="gssp-value">{gsspValue}</div>
</main>
)
}

View File

@@ -0,0 +1,10 @@
const value = await Promise.resolve(42)
export default function Index({ appValue }) {
return (
<main>
<div id="app-value">{appValue}</div>
<div id="page-value">{value}</div>
</main>
)
}

View File

@@ -0,0 +1,7 @@
export async function getServerSideProps() {
throw new Error('BOOM')
}
export default function Page() {
return <div>hello</div>
}