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

  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

  1. Setup project to working with mocha
  • Install mocha module

npm install --save mocha chai

  1. 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

  1. Display your choice pass/fail messages for each test

************************************************************************************

below is the downloaded file

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;

};

***********************************

I just need #4 and #5. thanks

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!