Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kaelzhang/roe-mock

Mock of roe server for testing
https://github.com/kaelzhang/roe-mock

roe testing

Last synced: 20 days ago
JSON representation

Mock of roe server for testing

Awesome Lists containing this project

README

        

[![Build Status](https://travis-ci.org/kaelzhang/roe-mock.svg?branch=master)](https://travis-ci.org/kaelzhang/roe-mock)
[![Coverage](https://codecov.io/gh/kaelzhang/roe-mock/branch/master/graph/badge.svg)](https://codecov.io/gh/kaelzhang/roe-mock)

# roe-mock

Mock of roe server for testing

## Install

```sh
$ npm i roe-mock
```

## Usage

```js
const path = require('path')
const create = require('roe-mock')

const baseDir = path.join(__dirname, 'fixtures', 'myApp')
const mock = await create(baseDir)

// Write test cases as well as supertest
await mock.get('/foo/bar')
.expect(200)
```

## create(baseDir, options?)

- **baseDir** `path` base directory contains the roe app
- **options?** `Object`
- **copy?** `boolean=false` if true, roe-mock will copy things inside `baseDir` to an temp dir before creating the application

Creates an [`supertest`](https://npmjs.org/package/supertest) instance with an additional method `listen(port)` to start the server:

```js
const {
listen
} = await create(baseDir)

listen(8888) // Server started at 127.0.0.1:8888
```

## License

MIT