0
0
mirror of https://github.com/honojs/hono.git synced 2024-12-01 10:51:01 +00:00
hono/runtime_tests/wrangler/index.test.ts
Yusuke Wada f29761e16b
chore: move runtime tests into runtime_tests (#1062)
* chore: move runtime tests into `runtime_tests`

* fixed ci
2023-05-02 21:16:17 +09:00

32 lines
800 B
TypeScript

import { unstable_dev } from 'wrangler'
import type { UnstableDevWorker } from 'wrangler'
describe('Wrangler', () => {
let worker: UnstableDevWorker
beforeAll(async () => {
worker = await unstable_dev('./runtime_tests/wrangler/index.ts', {
vars: {
NAME: 'Cloudflare',
},
experimental: { disableExperimentalWarning: true },
})
})
afterAll(async () => {
await worker.stop()
})
it('Should return Hello World', async () => {
const res = await worker.fetch('/')
expect(res.status).toBe(200)
expect(await res.text()).toBe('Hello Wrangler!')
})
it('Should return the environment variable', async () => {
const res = await worker.fetch('/env')
expect(res.status).toBe(200)
expect(await res.text()).toBe('Cloudflare')
})
})