Only run certain tests in Mocha

Imagine you have a large test suite for a project.
Possible with some setup and teardown to create a reproducible world in which your tests can run.

There are times you just want to run some tests instead of the whole pack. Don't wait for that one time consuming test time and time again.

Solution: mocha --grep 'selector'

-g, --grep <pattern>        only run tests matching <pattern>

This will search in the name parameters of your it() and describe() functions and only run the matching tests. Ensure you use describe() functions regulary to group tests. This will give you really fine-grained control over what tests to run.


mocha --grep 'selector name'