filipedeschamps / rss-feed-emitter

Super RSS News Feed aggregator written in Node.js and ES6

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

17. Bonus: how to watch tests with Mocha

filipedeschamps opened this issue · comments

Like I said in the previous issue, from now on you will just keep iterating over the same things, which are:

  • Continue to develop the implementation details
  • Continue to write tests to cover your module

You need to keep doing them in parallel. What I do is open both the module and test code, and in the bottom, I keep watching the tests running automatically while I keep changing those files:

image

If I do something wrong or I'm in the middle of the development, it's very easy to see when everything is ok again.

image

Watch script

This is very easy to do, just add this to your scripts property inside package.json:

"test-unit-watch": "mocha --watch --compilers js:babel-core/register test/unit/**/*.spec.js"

Basically we're just adding a --watch flag to Mocha.

Now in the command line run this and start working on your code:

$ npm run test-unit-watch

Different from integration tests, unit test need to be fast. In this case, it will have a lot of network interaction, and this is really slow, I will show you how to mock http requests in the next step.

Next step

18. Bonus: how to mock requests in Unit Tests