Skip to main content

Watch and Run Tests

/ javascript

I used to put a script in each package.json file called dev. The idea was to watch for changes and then run tests. No need to pollute the scripts section because we can abstract it to a system wide command.

First thing to do is npm install -g watch.

Then add an alias to .zshrc (or whatever) file:

alias dev='watch "npm test" . --ignoreDirectoryPattern=/node_modules/ --ignoreDotFiles'

Voila. Just run dev in the target tld.