2023-03-06 12:12:22 +00:00
|
|
|
import { unstable_dev } from 'wrangler'
|
|
|
|
import type { UnstableDevWorker } from 'wrangler'
|
|
|
|
|
|
|
|
describe('Wrangler', () => {
|
|
|
|
let worker: UnstableDevWorker
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
2023-05-02 12:16:17 +00:00
|
|
|
worker = await unstable_dev('./runtime_tests/wrangler/index.ts', {
|
2023-03-06 12:12:22 +00:00
|
|
|
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')
|
|
|
|
})
|
|
|
|
})
|