@@ -3,9 +3,9 @@ import { getLogger } from 'lambda-local'
3
3
import { HttpResponse , http , passthrough } from 'msw'
4
4
import { setupServer } from 'msw/node'
5
5
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'
7
7
import { type FixtureTestContext } from '../utils/contexts.js'
8
- import { createFixture , invokeFunction , runPlugin } from '../utils/fixture.js'
8
+ import { createFixture , invokeEdgeFunction , invokeFunction , runPlugin } from '../utils/fixture.js'
9
9
import { generateRandomObjectID , startMockBlobStore } from '../utils/helpers.js'
10
10
import { nextVersionSatisfies } from '../utils/next-version-helpers.mjs'
11
11
@@ -63,15 +63,44 @@ afterEach(() => {
63
63
64
64
// https://github.com/vercel/next.js/pull/77808 makes turbopack builds no longer gated only to canaries
65
65
// 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' ) ) (
67
67
'Test that the hello-world-turbopack next app is working' ,
68
- async ( ctx ) => {
69
- await createFixture ( 'hello-world-turbopack' , ctx )
70
- await runPlugin ( ctx )
71
-
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!' )
68
+ ( ) => {
69
+ test < FixtureTestContext > ( 'regular page is working' , async ( ctx ) => {
70
+ await createFixture ( 'hello-world-turbopack' , ctx )
71
+ await runPlugin ( ctx )
72
+
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
+ } )
88
+
89
+ test < FixtureTestContext > ( 'middleware is working' , async ( ctx ) => {
90
+ await createFixture ( 'hello-world-turbopack' , ctx )
91
+ await runPlugin ( ctx )
92
+
93
+ const pathname = '/middleware/test'
94
+
95
+ const response = await invokeEdgeFunction ( ctx , {
96
+ functions : [ '___netlify-edge-handler-middleware' ] ,
97
+ url : pathname ,
98
+ } )
99
+
100
+ expect ( response . status ) . toBe ( 200 )
101
+ expect ( await response . json ( ) ) . toEqual ( {
102
+ message : `Hello from middleware at ${ pathname } ` ,
103
+ } )
104
+ } )
76
105
} ,
77
106
)
0 commit comments