mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 21:55:11 +00:00
26 lines
799 B
JavaScript
26 lines
799 B
JavaScript
import { promises as fsp } from 'fs'
|
|
import { resolve } from 'pathe'
|
|
import { Miniflare } from 'miniflare'
|
|
|
|
import { setupTest, testNitroBehavior } from './_tests.mjs'
|
|
|
|
// TODO: fix SyntaxError: Unexpected end of input on script executation
|
|
describe('nitro:preset:cloudflare', () => {
|
|
const ctx = setupTest('cloudflare')
|
|
testNitroBehavior(ctx, async () => {
|
|
const script = await fsp.readFile(resolve(ctx.outDir, 'server/index.mjs'), 'utf-8')
|
|
const mf = new Miniflare({ script })
|
|
|
|
return async ({ url, headers, method, body }) => {
|
|
const data = await mf.dispatchFetch('http://localhost' + url, {
|
|
headers: headers || {},
|
|
method: method || 'GET',
|
|
redirect: null,
|
|
body: body || null
|
|
}).then(r => r.text())
|
|
|
|
return { data }
|
|
}
|
|
})
|
|
})
|