Skip to content

Commit

Permalink
Update switchable runtime snapshot for Turbopack
Browse files Browse the repository at this point in the history
  • Loading branch information
timneutkens committed Mar 18, 2024
1 parent 8264ca8 commit 647979d
Show file tree
Hide file tree
Showing 2 changed files with 126 additions and 31 deletions.
152 changes: 124 additions & 28 deletions test/e2e/switchable-runtime/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,34 +184,130 @@ describe('Switchable runtime', () => {
const manifest = await readJson(
join(context.appDir, '.next/server/middleware-manifest.json')
)
expect(manifest).toMatchObject({
functions: {
'/api/hello': {
files: expect.arrayContaining([
'server/edge-runtime-webpack.js',
'server/pages/api/hello.js',
]),
name: 'pages/api/hello',
page: '/api/hello',
matchers: [
{ regexp: '^/api/hello$', originalSource: '/api/hello' },
],
wasm: [],
},
'/api/edge': {
files: expect.arrayContaining([
'server/edge-runtime-webpack.js',
'server/pages/api/edge.js',
]),
name: 'pages/api/edge',
page: '/api/edge',
matchers: [
{ regexp: '^/api/edge$', originalSource: '/api/edge' },
],
wasm: [],
},
},
})
if (process.env.TURBOPACK) {
expect(manifest).toMatchInlineSnapshot(`
{
"functions": {
"/api/edge": {
"files": [
"server/server-reference-manifest.js",
"server/middleware-build-manifest.js",
"server/middleware-react-loadable-manifest.js",
"server/next-font-manifest.js",
"server/edge/chunks/_90eaa1._.js",
"server/edge/chunks/pages_api_edge_167089.js",
"server/edge/chunks/edge-wrapper_c60acd.js",
"server/edge/chunks/edge-wrapper_4a7104.js",
],
"matchers": [
{
"locale": false,
"originalSource": "/api/edge",
"regexp": "^/api/edge(?:/)?$",
},
],
"name": "/api/edge",
"page": "/api/edge",
},
"/api/hello": {
"files": [
"server/server-reference-manifest.js",
"server/middleware-build-manifest.js",
"server/middleware-react-loadable-manifest.js",
"server/next-font-manifest.js",
"server/edge/chunks/_d84e76._.js",
"server/edge/chunks/pages_api_hello_ee733f.js",
"server/edge/chunks/edge-wrapper_181e59.js",
"server/edge/chunks/edge-wrapper_8a0dd5.js",
],
"matchers": [
{
"locale": false,
"originalSource": "/api/hello",
"regexp": "^/api/hello(?:/)?$",
},
],
"name": "/api/hello",
"page": "/api/hello",
},
},
"middleware": {},
"sortedMiddleware": [],
"version": 2,
}
`)
} else {
expect(manifest).toMatchInlineSnapshot(`
{
"functions": {
"/api/edge": {
"assets": [],
"files": [
"server/edge-runtime-webpack.js",
"server/pages/api/edge.js",
],
"matchers": [
{
"originalSource": "/api/edge",
"regexp": "^/api/edge$",
},
],
"name": "pages/api/edge",
"page": "/api/edge",
"wasm": [],
},
"/api/hello": {
"assets": [],
"files": [
"server/edge-runtime-webpack.js",
"server/pages/api/hello.js",
],
"matchers": [
{
"originalSource": "/api/hello",
"regexp": "^/api/hello$",
},
],
"name": "pages/api/hello",
"page": "/api/hello",
"wasm": [],
},
},
"middleware": {},
"sortedMiddleware": [],
"version": 2,
}
`)
}

// expect(manifest).toMatchObject({
// functions: {
// '/api/hello': {
// files: expect.arrayContaining([
// 'server/edge-runtime-webpack.js',
// 'server/pages/api/hello.js',
// ]),
// name: 'pages/api/hello',
// page: '/api/hello',
// matchers: [
// { regexp: '^/api/hello$', originalSource: '/api/hello' },
// ],
// wasm: [],
// },
// '/api/edge': {
// files: expect.arrayContaining([
// 'server/edge-runtime-webpack.js',
// 'server/pages/api/edge.js',
// ]),
// name: 'pages/api/edge',
// page: '/api/edge',
// matchers: [
// { regexp: '^/api/edge$', originalSource: '/api/edge' },
// ],
// wasm: [],
// },
// },
// })
}
})

Expand Down
5 changes: 2 additions & 3 deletions test/turbopack-tests-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6820,13 +6820,12 @@
"Switchable runtime Switchable runtime (dev) should be able to navigate between edge SSR routes without any errors",
"Switchable runtime Switchable runtime (dev) should be possible to switch between runtimes in API routes",
"Switchable runtime Switchable runtime (dev) should be possible to switch between runtimes in pages",
"Switchable runtime Switchable runtime (dev) should build /api/hello and /api/edge as an api route with edge runtime",
"Switchable runtime Switchable runtime (dev) should not consume server.js file extension",
"Switchable runtime Switchable runtime (dev) should not include edge api routes and edge ssr routes into dev middleware manifest",
"Switchable runtime Switchable runtime (dev) should sort edge SSR routes correctly"
],
"failed": [
"Switchable runtime Switchable runtime (dev) should build /api/hello and /api/edge as an api route with edge runtime"
],
"failed": [],
"pending": [
"Switchable runtime Switchable runtime (dev) should be possible to switch between runtimes with same content",
"Switchable runtime Switchable runtime (dev) should give proper errors for invalid runtime in app dir",
Expand Down

0 comments on commit 647979d

Please sign in to comment.