lundi 7 décembre 2015

Why use supertest instead of unit tests for expressJS?

While searching for how to test my node.js software, I came accross many answers advising to use Supertest.

Before using Supertest I was testing my app this way :

app.get('/', base_road);
function base_road(req, res) {
   return res.json("Hello world");
}

it("base road", function() {
  base_road(mocked_req, {json: function(data) {
      assert.isEqual(data, "Hello world");
  }});
});

I'm not really happy with this way of testing as the mocking can become very hard to read, but I feel like if I use supertest I'll be closer to e2e than unit testing.

Should I use supertest to do unit testing ? Is my actual way of testing my app correct ?

Aucun commentaire:

Enregistrer un commentaire