Created
October 3, 2016 18:05
-
-
Save yamalight/370306d4027d70dcf29650be9db30f91 to your computer and use it in GitHub Desktop.
Koa and supertest example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const test = require('tape'); | |
const koa = require('koa'); | |
const supertest = require('supertest'); | |
const app = koa(); | |
app.use(function *(){ | |
this.body = 'Hello World'; | |
}); | |
let server; | |
let request; | |
test('Start server', t => { | |
server = app.listen(); | |
request = supertest(server); | |
t.end(); | |
}) | |
test('Koa test', t => { | |
request | |
.get('/') | |
.expect(200) | |
.end((err, res) => { | |
if (err) throw err; | |
t.equals(res.text, 'Hello World'); | |
t.end(); | |
}); | |
}); | |
test('Shutdown server', t => { | |
server.close(); | |
t.end(); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@polRk return it as a response?