Files
4588a73542 Convert tests using createNext -> nextTestSetup (#93767)
## What?

Converts existing `createNext()` usage into `nextTestSetup()`. 

`createNext()` was the setup step we had before `nextTestSetup()` was
added.

This PR focused on the simple conversion cases. There will be a
follow-up to complete the last few.

---------

Co-authored-by: Cursor <[email protected]>
2026-05-12 13:16:31 +02:00

49 lines
1.1 KiB
TypeScript

import path from 'path'
import { FileRef, nextTestSetup } from 'e2e-utils'
import { renderViaHTTP } from 'next-test-utils'
const files = {
'app/layout.jsx': `
export default function AppLayout({ children }) {
return (
<html>
<head>
<title>WASM Import</title>
</head>
<body>
{children}
</body>
</html>
)
}
`,
'app/page.jsx': `
import wasm from '../wasm/add.wasm?module'
const instance$ = WebAssembly.instantiate(wasm);
async function addOne(a) {
const { exports } = await instance$;
return exports.add_one(a);
}
export default async function Page() {
const two = await addOne(1)
return \`1 + 1 is: $\{two}\`
}
export const runtime = "edge"
`,
'wasm/add.wasm': new FileRef(path.join(__dirname, 'add.wasm')),
}
describe('app-dir edge runtime with wasm', () => {
const { next } = nextTestSetup({
files,
})
it('should have built', async () => {
const html = await renderViaHTTP(next.url, '/')
expect(html).toContain('1 + 1 is: 2')
})
})