Options Flashcards
Review the Mocha command line options, in both long and short form.
–colors
force enabling of colors (Long version of -c)
–growl
(Long Form) enable growl notification support
–invert
inverts –grep matches (Long version of -i)
–slow
“slow” test threshold in milliseconds [75]
–timeout
set test-case timeout in milliseconds [2000]
–bail
(Long Form) bail after first test failure
–async-only
(Long form) force all tests to take a callback (async)
–check-leaks
By default Mocha will not check for global variables leaked while running tests, to enable this pass –check-leaks, to specify globals that are acceptable use –globals, for example –globals jQuery,MyLib.
–compilers :,…
use the given module(s) to compile files
–debug
Enables node’s debugger support, this executes your script(s) with node debug <file …> allowing you to step through code and break with the debugger statement.</file>
–debug-brk
enable node’s debugger breaking on the first line
–help
The long form version of the comand line option for getting help information.
–globals <names></names>
Accepts a comma-delimited list of accepted global variable names. For example suppose your app deliberately exposes a global named app and YUI, you may want to add –globals app,YUI.
–interfaces
display available interfaces
–no-colors
force disabling of colors
–recursive
include sub directories
–reporter
specify the reporter to use
–reporters
display available reporters
–require
require the given module
–verion
How do you get the version number, long form?
–ui
The –ui option lets you specify the interface to use, defaulting to “bdd”.
–watch
watch files for changes
-b
(Short Form) bail after first test failure
-A
(Short Term) force all tests to take a callback (async)
-c
force enabling of colors
-C
force disabling of colors
-G
(Short Form) enable growl notification support
-g
The –grep option when specified will trigger mocha to only run tests matching the given pattern which is internally compiled to a RegExp.
Suppose for example you have “api” related tests, as well as “app” related tests, as shown in the following snippet; One could use –grep api or –grep app to run one or the other. The same goes for any other part of a suite or test-case title, –grep users would be valid as well, or even –grep GET.
-h
The short form comand line option for getting help information.
-i
inverts –grep matches
-R
specify the reporter to use
-r
The –require option is useful for libraries such as should.js, so you may simply –require should instead of manually invoking require(‘should’) within each test file. Note that this works well for should as it augments Object.prototype, however if you wish to access a module’s exports you will have to require them, for example var should = require(‘should’).
-s
“slow” test threshold in milliseconds [75]
-d
(Short Form) Enables node’s debugger support, this executes your script(s) with node debug <file …> allowing you to step through code and break with the debugger statement.</file>
-t
set test-case timeout in milliseconds [2000]
-u
The –u option lets you specify the interface to use, defaulting to “bdd”.
-V
How do you get the version number, short form?
-w
watch files for changes
What is the default timeout?
2000 ms (2 seconds)
–grep
The –grep option when specified will trigger mocha to only run tests matching the given pattern which is internally compiled to a RegExp.
Suppose for example you have “api” related tests, as well as “app” related tests, as shown in the following snippet; One could use –grep api or –grep app to run one or the other. The same goes for any other part of a suite or test-case title, –grep users would be valid as well, or even –grep GET.