You can easily convert a single Mocha test or directory of Mocha tests to Suman tests with the following command:
$ suman --convert --src=[src-dir/src-file] --dest=[dest-dir]
Making the switch, taking the plunge
The best steps to start making the switch from Mocha to Suman are as follows:
Create a commit or tag before you do anything further; the commit message might be "last commit pre-suman-conversion"
Rename your "test" directory to "test-old" or whatever your test directory is called if it's not "test"
=>
mv test test-old
// orgit mv test test-old
(this will automatically stage the change)$ suman --convert test-old test
This should run very quickly, much less than 1 second. Now you have Suman tests replacing all your Mocha tests in your original test directory!
You can compare the new Suman tests with the old Mocha tests in test-old for awhile, for reference. Please be aware of the common catches and caveats associated with converting Mocha tests to Suman tests, below. We are working on making the conversion close to 100% reliable.
Here are the current pitfalls and caveats with regard to converting from Mocha to Suman:
Suman test cases and hooks use a singular param t (t itself is an error-first callback and callback functions belong to the t function-object, and they can be called in any context, without problem).
- Problem caused by: hooks that forgo the anonymous wrapper function
normally we have:
before(function(done){ //mocha version
someHelperFn(done);
});
this.before.cb(t => { //suman equivalent
someHelperFn(t);
});