Skip to content

Commit eafe8b6

Browse files
committed
test: make sure we do SSR to ensure rendering fully works, add edge runtime page
1 parent 22fdac1 commit eafe8b6

File tree

3 files changed

+33
-10
lines changed

3 files changed

+33
-10
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { connection } from 'next/server'
2+
3+
export const runtime = 'edge'
4+
5+
export default async function Page() {
6+
await connection()
7+
return <h1>Hello, Next.js!</h1>
8+
}
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1-
export default function Page() {
1+
import { connection } from 'next/server'
2+
3+
export default async function Page() {
4+
await connection()
25
return <h1>Hello, Next.js!</h1>
36
}

tests/integration/hello-world-turbopack.test.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { getLogger } from 'lambda-local'
33
import { HttpResponse, http, passthrough } from 'msw'
44
import { setupServer } from 'msw/node'
55
import { v4 } from 'uuid'
6-
import { afterAll, afterEach, beforeAll, beforeEach, expect, test, vi } from 'vitest'
6+
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, test, vi } from 'vitest'
77
import { type FixtureTestContext } from '../utils/contexts.js'
88
import { createFixture, invokeFunction, runPlugin } from '../utils/fixture.js'
99
import { generateRandomObjectID, startMockBlobStore } from '../utils/helpers.js'
@@ -63,15 +63,27 @@ afterEach(() => {
6363

6464
// https://github.com/vercel/next.js/pull/77808 makes turbopack builds no longer gated only to canaries
6565
// allowing to run this test on both stable and canary versions of Next.js
66-
test.skipIf(!nextVersionSatisfies('>=15.3.0-canary.43'))<FixtureTestContext>(
66+
describe.skipIf(!nextVersionSatisfies('>=15.3.0-canary.43'))(
6767
'Test that the hello-world-turbopack next app is working',
68-
async (ctx) => {
69-
await createFixture('hello-world-turbopack', ctx)
70-
await runPlugin(ctx)
68+
() => {
69+
test<FixtureTestContext>('regular page is working', async (ctx) => {
70+
await createFixture('hello-world-turbopack', ctx)
71+
await runPlugin(ctx)
7172

72-
// test the function call
73-
const home = await invokeFunction(ctx)
74-
expect(home.statusCode).toBe(200)
75-
expect(load(home.body)('h1').text()).toBe('Hello, Next.js!')
73+
// test the function call
74+
const home = await invokeFunction(ctx)
75+
expect(home.statusCode).toBe(200)
76+
expect(load(home.body)('h1').text()).toBe('Hello, Next.js!')
77+
})
78+
79+
test<FixtureTestContext>('edge page is working', async (ctx) => {
80+
await createFixture('hello-world-turbopack', ctx)
81+
await runPlugin(ctx)
82+
83+
// test the function call
84+
const home = await invokeFunction(ctx, { url: '/edge-page' })
85+
expect(home.statusCode).toBe(200)
86+
expect(load(home.body)('h1').text()).toBe('Hello, Next.js!')
87+
})
7688
},
7789
)

0 commit comments

Comments
 (0)