O'Reilly logo

Building APIs with Node.js by Caio Ribeiro Pereira

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

©  Caio Ribeiro Pereira 2016

Caio Ribeiro Pereira, Building APIs with Node.js , 10.1007/978-1-4842-2442-7_9

9. Testing the Application: Part 2

Caio Ribeiro Pereira

(1)São Vicente - SP, São Paulo, Brazil

Continuing the test implementation, now focus next on writing some tests for the resources: tasks and users.

Testing a Task’s Endpoints

To test the endpoints of a task’s resource, we are going to cheat the JWT authentication . After all, it will be necessary to correctly test the results of this resource and also the other resources that involves user authentication. To start, let’s create the structure for the tasks test.

Create the file test/routes/tasks.js with the following code.

 1   import jwt from "jwt-simple"; 2    3   describe("Routes: Tasks", ...

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