When working in mocha, oftenly you don't want to run all the test cases. Mocha provides you the feature to specify which exactly you want to run.
Running a single test file
Using mocha-cli you can easily run a single. This can be accomplished with the grep option when running the mocha command.
Syntax:
$ mocha --grep users.js
or
$ mocha test users.js
Running a single test
If you want to run a single test you can use the .only() method:-
it.only(function () {
// this test will run
});
it(function () {
// this test will be skipped
});
Skipping a test
If you need to skip a test case, you can use the .skip() method like as follows:
it.skip(function () {
// this test will be skipped
});
it(function () {
// this test will be executed
});
0 Comment(s)