Skip to content

Commit

Permalink
migrate test
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Feb 6, 2024
1 parent 0ba1c20 commit e2fa20f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
16 changes: 7 additions & 9 deletions test/e2e/app-dir/app-external/app-external.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 () => {
Expand Down
7 changes: 7 additions & 0 deletions test/e2e/app-dir/app-external/app/cjs/server/page.js
Original file line number Diff line number Diff line change
@@ -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 <p>{text}</p>
}
5 changes: 0 additions & 5 deletions test/e2e/app-dir/app-external/middleware.js
Original file line number Diff line number Diff line change
@@ -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()
}

0 comments on commit e2fa20f

Please sign in to comment.