DongThin / my-love-e2e-testing

e2e testing with cypress
2 stars 0 forks source link

Mocking with Sinon for Unit Testing #10

Closed alang-dev closed 6 months ago

alang-dev commented 6 months ago

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 the taxCalculation function to demonstrate the difference between unit tests and integration tests.

Tasks:

Additional Notes:

Same requirement for insurance calculator


alang-dev commented 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)