0.3.0 • Published 3 years ago
@rocket-scripts/mockup v0.3.0
@rocket-scripts/mockup
import { createMockupServer } from '@rocket-scripts/mockup'
describe('example', () => {
const server = createMockupServer()
beforeAll(async () => {
await server.start((router) => {
router.get('/api', async (ctx) => {
ctx.body = 'ok';
})
})
})
afterAll(async () => {
await server.stop()
})
test('should get ok', async () => {
const body: string = await fetch(`${server.getBasePath()}/api`).then(res => res.text())
expect(body).toBe('ok')
})
})