Skip to content

Latest commit

 

History

History
18 lines (12 loc) · 626 Bytes

README.md

File metadata and controls

18 lines (12 loc) · 626 Bytes

axios-mock-jest-example

Sample code for mocking API's with axios-mock-adapter for use in jest tests.

Running the sample

To run the sample run the following commands:

npm install
npm test

Test case

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.

Why do we mock the response?

We mock responses to ensure that our application handles both valid and invalid responses, appropriately.