koa with supertest for ava or mocha
import app from './app'
import superkoa from './superkoa'
test.cb("superkoa()", t => {
superkoa(app)
.get("/")
.expect(200, function (err, res) {
t.ifError(err)
var userId = res.body.id;
t.is(res.text, 'Hello Koa', 'res.text == Hello Koa')
t.end()
});
});
with generator
test('yield superkoa()', function * (t) {
let res = yield superkoa(app)
.get('/')
t.is(200, res.status)
t.is(res.text, 'Hello Koa', 'res.text == Hello Koa')
})
with async/await
test('async superkoa()', async (t) => {
let res = await superkoa(app)
.get('/')
t.is(200, res.status)
t.is(res.text, 'Hello Koa', 'res.text == Hello Koa')
})
$ npm test
with watch mode
npm test -- -w