Question
Download given node project name lab2_mocha_test ZIP file Add package.json file to the project Change directory to lab2_mocha_test npm init -y Setup project to working
- Download given node project name lab2_mocha_test ZIP file
- Add package.json file to the project
Change directory to lab2_mocha_test
npm init -y
- Setup project to working with mocha
- Install mocha module
npm install --save mocha chai
- 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
- Display your choice pass/fail messages for each test
*Content given in the lab2_mocha_test zip file was a file called calculator.js which consist the following:
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started