O'Reilly logo

Express.js Blueprints by Ben Augarten, Marc Kuo, Eric Lin, Aidha Shaikh, Fabiano Pereira Soriani, Geoffrey Tisserand, Chiqing Zhang, Kan Zhang

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Let's perform some tests

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) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required