Package Exports
- @open-draft/test-server
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@open-draft/test-server) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Test Server
Creates HTTP and HTTPS server with an optional server middleware for testing purposes. Designed to re-create the "actual" server behavior.
Getting started
Install
$ npm install @open-draft/test-serverUsage
import fetch from 'node-fetch'
import { createServer } from '@open-draft/test-server'
let server
beforeAll(async () => {
server = await createServer((app) => {
app.get('/numbers', (req, res) => {
return res.status(200).json([1, 2, 3])
})
})
})
afterAll(async () => {
await server.close()
})
test('fetches all the numbers', async () => {
const res = await fetch(server.makeHttpUrl('/books'))
expect(res.status).toBe(200)
expect(await res.json()).toEqual([1, 2, 3])
})