rsnext/test/e2e/app-dir/edge-runtime-node-compatibility/edge-runtime-node-compatibility.test.ts
Gal Schlezinger 6b09bc86a8
[edge] limit the api surface of util (#47292)
This makes sure that what works locally will work in production.
2023-03-20 10:29:00 +01:00

51 lines
1.3 KiB
TypeScript

import { createNextDescribe } from 'e2e-utils'
createNextDescribe(
'edge runtime node compatibility',
{
files: __dirname,
},
({ next }) => {
it('[app] supports node:buffer', async () => {
const res = await next.fetch('/buffer', {
method: 'POST',
body: 'Hello, world!',
})
const json = await res.json()
expect(json).toEqual({
'Buffer === B.Buffer': true,
encoded: Buffer.from('Hello, world!').toString('base64'),
exposedKeys: expect.arrayContaining([
'constants',
'kMaxLength',
'kStringMaxLength',
'Buffer',
'SlowBuffer',
]),
})
})
it('[pages/api] supports node:buffer', async () => {
const res = await next.fetch('/api/buffer', {
method: 'POST',
body: 'Hello, world!',
})
const json = await res.json()
expect(json).toEqual({
'B2.Buffer === B.Buffer': true,
'Buffer === B.Buffer': true,
'typeof B.Buffer': 'function',
'typeof B2.Buffer': 'function',
'typeof Buffer': 'function',
encoded: 'SGVsbG8sIHdvcmxkIQ==',
exposedKeys: expect.arrayContaining([
'constants',
'kMaxLength',
'kStringMaxLength',
'Buffer',
'SlowBuffer',
]),
})
})
}
)