Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

*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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Knowledge Discovery In Databases

Authors: Gregory Piatetsky-Shapiro, William Frawley

1st Edition

0262660709, 978-0262660709

More Books

Students also viewed these Databases questions