Testing Mocha and Test Duration
In the previous tutorial we looked at real live example code for mocha; this tutorial will examine the different test durations that exist and how we can test mocha.
TEST DURATION
Many reporters display test duration and then flag tests that are slow (default: 75ms), as shown below with the "spec" reporter:
Three levels of test duration exist (they are in the image below):
- FAST: All tests that run within half of the "slow" threshold shows the duration in green (if at all).
- NORMAL: All tests that run exceeding half of the threshold (but still within it) shows the duration in yellow.
- SLOW: All tests that run exceeding the threshold shows the duration in red.
If you want to change what is considered "slow", you can make use of the slow() method:
describe('something slow', function() {
this.slow(300000); // five minutes
it('it should take long enough for me to go make a sandwich', function() {
// ...
});
});
TESTING MOCHA
For you to run Mocha's tests, you need either GNU Make or compatible; Cygwin should be sufficient.
- You should cd to /path/to/mocha
- Then run npm install
- Finally run npm tes
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/mocha/testing-mocha.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics