Sample code for mocking API's with axios-mock-adapter for use in jest tests.
To run the sample run the following commands:
npm install
npm test
Our function uses axios
to retrieve a JSON file containing a deviceModel
. Then our function evaluates if the uid
of the deviceModel
matches a particular value and returns the result.
We mock responses to ensure that our application handles both valid and invalid responses, appropriately.