There are 3 files involved in this:
src/__mocks__/axios.js
: This is used by jest to mock the real axios module while running tests... we aren't really using this mock as we'll override it in each test.src/linkValidate.js
: This is our actual code that we want to testsrc/linkValidate.test.js
: Our tests... we import axios, although this is the mocked axios thanks to Jest detecting our special__mocks__
folder... we will mock it for each of the 2 tests with a success, and later a failure. Then we'll make sure our code did what it was expected to do.