rsnext/test/e2e/edge-runtime-uses-edge-light-import-specifier-for-packages/edge-runtime-uses-edge-light-import-specifier-for-packages.test.ts
Gal Schlezinger 282c1a0637
[edge] support edge-light exports when bundling edge functions (#45188)
This PR implements `edge-light` as a main field for bundling edge
functions as defined in https://runtime-keys.proposal.wintercg.org

Resolves EC-614

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ]
[e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

---------
2023-02-16 13:30:34 -08:00

49 lines
1.4 KiB
TypeScript

import { createNextDescribe } from 'e2e-utils'
createNextDescribe(
'edge-runtime uses edge-light import specifier for packages',
{
files: __dirname,
packageJson: {
scripts: {
setup: 'cp -r ./node_modules_bak/* ./node_modules',
build: 'yarn setup && next build',
dev: 'yarn setup && next dev',
start: 'next start',
},
},
installCommand: 'yarn',
startCommand: (global as any).isNextDev ? 'yarn dev' : 'yarn start',
buildCommand: 'yarn 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({
edgeLightPackage: '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({
edgeLightPackage: '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({
edgeLightPackage: 'edge-light',
edgeLightPackageExports: 'edge-light',
})
})
}
)