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
- New Content published on w3resource :
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- React - JavaScript Library
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework