Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
You don't always have to type 'npm test' every time you want to check whether your changes pass or fail the tests. Mocha comes with a special '-- watch' flag that will automatically run any specified tests when it sees changes in a certain file or directory.
Video review
- You can write custom
mocha --watch
commands whenever you plan on working on one particular file a lot - You can also save a general
--watch
command in yourpackage.json
to run your tests all the time
For example:
"scripts": {
"test": "mocha",
"test:watch": "mocha --watch ./test ./"
}
The first argument describes the tests you want to run: all the tests in the ./test
directory. The second argument describes the files you want to watch for changes: all the files in the current directory ./
. You must include a .
at the start of your file path, or Mocha will get confused on which files youβre looking for.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up