Files
next.js/test/e2e/edge-runtime-uses-edge-light-import-specifier-for-packages/edge-runtime-uses-edge-light-import-specifier-for-packages.test.ts
Jiachi LiuandGitHub 8d28d5954e test: rename node_modules_bak to node_modules (#62066)
We switched to `pnpm` for testing instead of `yarn` for e2e tests
containing customized node_modules packages, it works with
`node_modules` folder before. Rename the existing `node_modules_bak`
hack to make it easy to test with.

Previously we use `yarn` but it will clean `node_modules` folder so we
have to use another script to copy packages, it's not a required thing
now so we can test package from node_modules directly without renaming
folders locally

Closes NEXT-2496
2024-02-15 00:42:35 +01:00

53 lines
2.0 KiB
TypeScript

import { createNextDescribe } from 'e2e-utils'
import { shouldRunTurboDevTest } from '../../lib/next-test-utils'
createNextDescribe(
'edge-runtime uses edge-light import specifier for packages',
{
files: __dirname,
packageJson: {
scripts: {
build: 'next build',
dev: `next ${shouldRunTurboDevTest() ? 'dev --turbo' : 'dev'}`,
start: 'next start',
},
},
installCommand: 'pnpm i',
startCommand: (global as any).isNextDev ? 'pnpm dev' : 'pnpm start',
buildCommand: 'pnpm build',
skipDeployment: true,
},
({ next }) => {
// In case you need to test the response object
it('pages/api endpoints import the correct module', async () => {
const res = await next.fetch('/api/edge')
const html = await res.json()
expect(html).toEqual({
// edge-light is only supported in `exports` and `imports` but webpack also adds the top level `edge-light` key incorrectly.
edgeLightPackage: process.env.TURBOPACK ? 'import' : 'edge-light',
edgeLightPackageExports: 'edge-light',
})
})
it('pages import the correct module', async () => {
const $ = await next.render$('/')
const text = JSON.parse($('pre#result').text())
expect(text).toEqual({
// edge-light is only supported in `exports` and `imports` but webpack also adds the top level `edge-light` key incorrectly.
edgeLightPackage: process.env.TURBOPACK ? 'import' : 'edge-light',
edgeLightPackageExports: 'edge-light',
})
})
it('app-dir imports the correct module', async () => {
const $ = await next.render$('/app-dir')
const text = JSON.parse($('pre#result').text())
expect(text).toEqual({
// edge-light is only supported in `exports` and `imports` but webpack also adds the top level `edge-light` key incorrectly.
edgeLightPackage: process.env.TURBOPACK ? 'import' : 'edge-light',
edgeLightPackageExports: 'edge-light',
})
})
}
)