Mocha has a --sort (short -S ) option that sorts test files: $ mocha --help [...] -S, -- sort sort test files [...].
I follow a totally seperate solution for this. Put all your tests in a folder named test/ and Create a file tests.js in the root directory in the order of ...
It'd be great if mocha would run tests in its definition order. Let's consider this example: var assert = require('assert'); var runOrder = 1; ...
In asynchronous tests, the same ordering applies. Test Foo should run before Bar even Foo takes much longer to execute, and Suite B should ...
Mocha.js provides functions that execute in a specific order and logs
Running tests in parallel mode allows Mocha to take advantage of
slow tests; file watcher support; global variable leak detection; optionally run tests
The call of mocha.run() in the code snippet above occurs before sum.test.js is loaded! The workaround is to keep script execution order the ...
a global hook; root-level hooks in single test files that run after tests
tests. Note: This example assumes you are already familiar with Mocha hooks.