3 javascript libraries in 5 minutes and 45 secondes
fernan_s
13K views
Open Source Your Knowledge, Become a Contributor
Technology knowledge has to be shared and made accessible for free. Join the movement.
Mocha.js
What is Mocha ?
Mocha is an easy JavaScript unit testing framework. It helps you validate the output of a function in a couple ways: to make sure it works as expected and to verify that updates don't break existing code.
Tests use the Assert
module. In a nutshell, an assert function that fails (returns false
) will make the test fail. Using the Assert
module, you can compare the actual output of a function to the expected output.
In this example, you will need to correct the tests in order to correctly validate the add
function.
Fix the unit tests
For more information on Mocha, follow this link.
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content
1
2
3
4
5
6
7
8
9
function add(nb1, nb2) {
return nb1 + nb2;
}
// {
module.exports = {
add: add
};
// }
Press desired key combination and then press ENTER.
1
var assert = require('assert');
Press desired key combination and then press ENTER.