Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ianwalter/test-server
Easily create a minimal Koa server for testing
https://github.com/ianwalter/test-server
koa mock-server server test test-server testing unit-testing
Last synced: about 2 months ago
JSON representation
Easily create a minimal Koa server for testing
- Host: GitHub
- URL: https://github.com/ianwalter/test-server
- Owner: ianwalter
- License: other
- Created: 2019-02-12T01:50:34.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-06-22T10:47:26.000Z (over 1 year ago)
- Last Synced: 2024-11-22T17:52:01.757Z (2 months ago)
- Topics: koa, mock-server, server, test, test-server, testing, unit-testing
- Language: JavaScript
- Homepage:
- Size: 526 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @ianwalter/test-server
> Easily create a minimal [Koa][koaUrl] or [Express][expressUrl] server for
> testing[![npm page][npmImage]][npmUrl]
[![CI][ciImage]][ciUrl]## About
Inspired by [create-test-server][ctsUrl].
## Installation
```console
yarn add @ianwalter/test-server --dev
```## Usage
```js
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][licenseUrl]
Created by [Ian Walter](https://iankwalter.com)
[koaUrl]: https://github.com/koajs/koa
[expressUrl]: https://expressjs.com/
[npmImage]: https://img.shields.io/npm/v/@ianwalter/test-server.svg
[npmUrl]: https://www.npmjs.com/package/@ianwalter/test-server
[ciImage]: https://github.com/ianwalter/test-server/workflows/CI/badge.svg
[ciUrl]: https://github.com/ianwalter/test-server/actions
[ctsUrl]: https://github.com/lukechilds/create-test-server
[licenseUrl]: https://github.com/ianwalter/test-server/blob/master/LICENSE