Skip to content

ianwalter/test-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@ianwalter/test-server

Easily create a minimal Koa or Express server for testing

npm page CI

About

Inspired by create-test-server.

Installation

yarn add @ianwalter/test-server --dev

Usage

const { test } = require('@ianwalter/bff')
const { createKoaServer } = require('@ianwalter/test-server')
const { requester } = require('@ianwalter/requester')

test('requester', ({ expect }) => {
  const server = await createKoaServer()
  server.use(ctx => (ctx.body = 'Hello World!'))
  const response = await requester.get(server.url)
  expect(response.body).toBe('Hello World!')
  await server.close()
})

License

Apache 2.0 with Commons Clause - See LICENSE

 

Created by Ian Walter