Question: 1) Download given node project name lab2_mocha_test ZIP file 2) Add package.json file to the project Change directory to lab2_mocha_test npm init -y 3) Setup
1) Download given node project name lab2_mocha_test ZIP file
2) Add package.json file to the project
Change directory to lab2_mocha_test
npm init -y
3) Setup project to working with mocha
Install mocha module
npm install --save mocha chai
4) Write test cases to perform calculator test
- Create test/calculator.js file to write all your test cases
-Write one success and one fail test of add, sub, div and mul for calculator.js
Sample Test cases
add(5, 2) expected result 7 PASS
add(5,2) expected result 8 FAIL
sub(5, 2) expected result 3 PASS
sub(5,2) expected result 5 FAIL
mul(5, 2) expected result 10 PASS
mul(5,2) expected result 12 FAIL
div(10, 2) expected result 5 PASS
div(10,2) expected result 2 FAIL
5) Display your choice pass/fail messages for each test
includes file called calculator.js with code below:
exports.add = function(i, j) {
return i + j;
};
exports.mul = function(i, j) {
return i * j;
};
exports.div = function(i, j) {
return i / j;
};
exports.sub = function(i, j) {
return i - j;
};
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
