With mocha, how do I run all tests that *don't* have (slow) in the name?
You can do this with a combination of two command line switches. Here is the relevant part of the documentation:
-g, --grep <pattern> only run tests matching <pattern>
-i, --invert inverts --grep matches
It looks to me like you are doing it for a page you are loading in a browser to run Mocha. To do this in the browser you can pass these parameters in the URL of the page:
grep
which approximately corresponds to the--grep
option on the command line. This narrows the tests run to those that match the expression passed togrep
. However, there is currently (even as of 2.0.1) no way to get Mocha to interpret this parameter as a regular expression. It is always interpreted as a string. That's why I said "approximately corresponds".--grep
on the command line is a regular expression but thegrep
parameter passed in a URL is a string.invert
which correspond to the--invert
option on the command line. This will invert the match performed bygrep
and thus selects the tests thatgrep
does not match.
So if you open you page by appending the following string ?grep=(slow)&invert=1
it will run the tests that do not have the string "(slow)"
in them.
Grep accepts a regex pattern, you can do it like this:
mocha --grep '^(?!.*\\b\(slow\)\\b)'