Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll

- 2x 2x
- 1.75x 1.75x
- 1.5x 1.5x
- 1.25x 1.25x
- 1.1x 1.1x
- 1x 1x
- 0.75x 0.75x
- 0.5x 0.5x
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 up-
Sheryl Darroch
Treehouse Project Reviewer0 Answers
-
Jan Maas
2,282 PointsWhen following along the JavaScript Unit Testing I cannot run any "mocha" commands
Posted by Jan MaasJan Maas
2,282 Points3 Answers
View all discussions for this video
Related 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