Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,18 +255,19 @@ Micro makes tests compact and a pleasure to read and write.
We recommend [ava](https://github.com/sindresorhus/ava), a highly parallel micro test framework with built-in support for async tests:

```js
const micro = require('micro');
const test = require('ava');
const listen = require('./listen');
const send = require('micro').send;
const listen = require('test-listen');
const request = require('request-promise');

test('my endpoint', async t => {
const fn = async function (req, res) {
send(res, 200, { test: 'woot' });
};
const url = await listen(fn);
const service = micro(async function (req, res) {
micro.send(res, 200, { test: 'woot' })
});

const url = await listen(service);
const body = await request(url);
t.same(body.test, 'woot');
t.deepEqual(JSON.parse(body).test, 'woot');
});
```

Expand Down