I am trying to learn testing and code coverage in Node.js but I keep running into troubles.
I use Mocha for the tests and istanbul (nyc) for the coverage.
I tried to write a simple web server with express that sends a response on get, the response being Hello, World.
Now to test my server I check two things
- Server sends back 200 (everything is ok)
- Server response when get is Hello, World
The test seems to work fine, if I change the assertions they break and everything seems to work fine, however I cant get the coverage to work properly, it tells me the functions are not covered and I really don't understand what I am doing wrong.
I run nyc mocha index.spec.js
to generate the coverage and here it is :
See the functions that I thought I tested appear to not be covered and I can't tell if it has to do with my code being asynchronous or my test being plain wrong. I would really appreciate any help on the matter.
via Kevin
No comments:
Post a Comment