Skip to Content
Building APIs with Node.js
book

Building APIs with Node.js

by Caio Ribeiro Pereira
December 2016
Intermediate to advanced
136 pages
2h 58m
English
Apress
Content preview from Building APIs with Node.js

©  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", ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Advanced Node.js Development

Advanced Node.js Development

Andrew Mead
Serverless Applications with Node.js

Serverless Applications with Node.js

Aleksandar Simovic, Slobodan Stojanovic

Publisher Resources

ISBN: 9781484224427Purchase book