O'Reilly logo

Hands-On Microservices with Node.js by Diogo Resende

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

Covering all code

For now, let's focus on adding coverage to our code. It's important to have it covered as much as possible when it's still just a small service. If we start adding tests and coverage when it's already big, you'll be frustrated, and it will be hard to find the motivation to cover it all.

This way, you'll find it rewarding to cover it in the beginning and keep the coverage percentage as high as possible along with code evolution.

Let's get back to our image upload test, and add another test:

it("should deny duplicated images", (done) => {    chai    .request(tools.service)    .post("/uploads/test_image_upload.png")    .set("Content-Type", "image/png")    .send(tools.sample)    .end((err, res) => {        chai.expect(res).to.have.status(200); chai.expect(res.body).to.have.status("ok"); ...

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