- Initialized git?
- Initialized npm?
- Install your packages with the command
npm install -D mocha chai- Flags:
- use
-Dto save the package(s) in thepackage.jsonfile under"devDependencies" - use
-Sto save the package(s) in thepackage.jsonfile under"dependencies"
- use
- Flags:
Packages for running, creating, and managing your tests are generally considered development dependencies. Use the -D flag.
- Mocha, by default, looks for test files in a directory called
test.- create your test files in this directory. here is a suggestion for file name:
*.spec.js* refers to the filename you're testing. If you're testing a module saved ascalculator.jsyour test file should be namedcalculator.spec.js
- create your test files in this directory. here is a suggestion for file name:
- Did you require
mochaand/orchai? - Initialize chai's
expectorshould? - Are you requiring the
fileyou're testing? ex.calculator.spec.jstests thecalculator.jsfile.calculator.jsneeds to be imported into thecalculator.spec.jsfile using node'srequirefunction. descblock? reference at mochajs.orgitblock? refernece at mochajs.org- assertions? reference at chaijs.com
- command:
mocha - keep watching:
mocha --watch - bail on first failure:
mocha --bail - all-in-one:
mocha --watch --bail
aw yiss.