In this chapter we omitted the disciplined TDD approach, since it has been covered multiple times in previous chapters. However, testing is slightly different in Koa.js, so let's highlight some of those differences.
We can still use supertest in the neat way that we did before, with one slight adjustment as follows:
var app = require('../src/app').callback();
We need to call the .callback()
method to return an object that we can pass to supertest. In fact, the returned object can even be mounted on top of an Express app.
Testing the routes to submit links is pretty straightforward:
var app = require('../src/app').callback(), Links = require('../src/models/links'); describe('Submit a link', function() { before(function(done) { Links.remove({}, function(err) { done(); }); }); it('should successfully submit a link', function (done) { request(app).post('/links') .send({title: 'google', URL: 'http://google.com'}) .expect(200, done...