Tuesday, September 22, 2020

Before continue exploring testing lets add nodemon.

With an automatic way to re run your test suit when you change either your test code or application code.

Usually we use nodemon like this :

nodemon --exec 'npm test'

nodemon will automatically restarts once changes are saved

By running it in that way you won’t have to switch to the terminal and rerun the npm command every time you make a change.

To this even easier we can set this script to run inside the package. Son scripts section by making a node script just after the test script

With this in place we can run the script from the terminal as opposes to having to type out this command every single time we want to run the test suit.

To run the script with a custom name like like test-watch all we need to do is run

npm run followed by the script name   test-watch

npm run test-watch

Now that we have a way to automatically restart our test suite, its time to continue exploring on testing in node