Occasionally you'll want to re-run just part of a test suite, for example, just to run the tests that failed in the previous run, or running tests for files in your application that have changed since the last run. There are a few ways to do this in node-tap.
--save=<file> option, you can write all failed tests to a file. If
that file exists, then only the tests in that file will be re-run.
For example, say that you have two tests
tap --save=tests.txt, it will run both files, because the file does
Let's say that
foo.test.js passes, but
bar.test.js fails. At the end of
the test run,
bar.test.js will be written to the
tests.txt file. So, if
tap --save=tests.txt again, it will only run
tap does this, it makes sure to keep the old coverage information around, and
only delete the coverage information related to that test file, so that you
don't end up with corrupted coverage results.
The workflow, then goes like this:
One useful way to work through a project is to run with both a
--bail. In this case, tap will bail out on the first failure, and
any tests that were skipped will be put into the save file, so you can fix the
failure, and then pick right back up where you were by running with
If you run tap with
-n), it will only run tests if the test
file, or any of the files it covers, have changed since the last run.
Because this depends on tracking which test covered which file, it requires that you have coverage enabled (which is on by default anyway).
If you specify a
option, then you can be very precise about which files under test should
trigger a re-run of the tests.