Closed alang-dev closed 6 months ago
const taxCalculatorStub = sinon.stub()
const net = proxyquire('../src/net.js', {
'./taxCalculator.js': taxCalculatorStub
})
const mockedTaxes = { rates: [], totalTax: 1 };
taxCalculatorStub.withArgs(54880000).returns(mockedTaxes)
Objective:
To enhance our understanding of unit testing and integration testing, we'll introduce Mock to create isolated unit tests for the
netCalculator.js
module. We'll specifically mock thetaxCalculation
function to demonstrate the difference between unit tests and integration tests.Tasks:
Mock taxCalculation Function:
npm install sinon -D
) AND proxyquire.taxCalculation
function within thenetCalculator.js
module.netCalculator.js
that focus on its internal logic, mocking the behavior oftaxCalculation
to isolate the unit under test.Understand Unit Testing vs. Integration Testing:
Additional Notes:
netCalculator.js
.Same requirement for insurance calculator