From e2fa20fa75545edcaf218adb5a892879bbe1917a Mon Sep 17 00:00:00 2001 From: Jiachi Liu Date: Tue, 6 Feb 2024 16:56:21 +0100 Subject: [PATCH] migrate test --- .../app-dir/app-external/app-external.test.ts | 16 +++++++--------- .../app-dir/app-external/app/cjs/server/page.js | 7 +++++++ test/e2e/app-dir/app-external/middleware.js | 5 ----- 3 files changed, 14 insertions(+), 14 deletions(-) create mode 100644 test/e2e/app-dir/app-external/app/cjs/server/page.js diff --git a/test/e2e/app-dir/app-external/app-external.test.ts b/test/e2e/app-dir/app-external/app-external.test.ts index bfb87282e2c85..87fc03136b653 100644 --- a/test/e2e/app-dir/app-external/app-external.test.ts +++ b/test/e2e/app-dir/app-external/app-external.test.ts @@ -37,7 +37,7 @@ createNextDescribe( buildCommand: 'yarn build', skipDeployment: true, }, - ({ next, isNextStart }) => { + ({ next }) => { it('should be able to opt-out 3rd party packages being bundled in server components', async () => { await next.fetch('/react-server/optout').then(async (response) => { const result = await resolveStreamResponse(response) @@ -246,15 +246,13 @@ createNextDescribe( }) it('should have proper tree-shaking for known modules in CJS', async () => { - const html = await next.render('/test-middleware') - expect(html).toContain('it works') + const html = await next.render('/cjs/server') + expect(html).toContain('resolve response') - if (isNextStart) { - const middlewareBundle = await next.readFile( - '.next/server/middleware.js' - ) - expect(middlewareBundle).not.toContain('image-response') - } + const outputFile = await next.readFile( + '.next/server/app/cjs/server/page.js' + ) + expect(outputFile).not.toContain('image-response') }) it('should use the same async storages if imported directly', async () => { diff --git a/test/e2e/app-dir/app-external/app/cjs/server/page.js b/test/e2e/app-dir/app-external/app/cjs/server/page.js new file mode 100644 index 0000000000000..f8fba4761b8ca --- /dev/null +++ b/test/e2e/app-dir/app-external/app/cjs/server/page.js @@ -0,0 +1,7 @@ +import { createResponse } from 'next-server-cjs-lib' + +export default async function Page() { + const response = createResponse('resolve response') + const text = await response.text() + return

{text}

+} diff --git a/test/e2e/app-dir/app-external/middleware.js b/test/e2e/app-dir/app-external/middleware.js index e333cde8a9e7c..61a7183fac735 100644 --- a/test/e2e/app-dir/app-external/middleware.js +++ b/test/e2e/app-dir/app-external/middleware.js @@ -1,10 +1,5 @@ -import { createResponse } from 'next-server-cjs-lib' import { respond } from 'compat-next-server-module' export async function middleware(request) { - if (request.nextUrl.pathname === '/test-middleware') { - return createResponse('it works') - } - return await respond() }