Skip to content

intolerance/axios-mock-jest-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Sample code for mocking API's with Jest and Axios

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published