Questions tagged [axios-mock-adapter]

82 questions
0
votes
2 answers

How to assert that app sends correct data to API server with POST request

I am writing React.js application talking to API server. I have read tons of articles on how to mock these calls and send some fake response from API. I can do testing using @testing-library/react, I can easily mock axios with axios-mock-adapter and…
YotKay
  • 1,127
  • 1
  • 9
  • 25
0
votes
1 answer

using axios-mock-adapter to test API call in use effect

I've been working through this problem for a couple days and believe I am close to a solution. I am trying to mock an API call which is triggered in my useEffect useEffect(() => { getAdminOrg(); // eslint-disable-next-line…
tdammon
  • 610
  • 2
  • 13
  • 39
0
votes
1 answer

How to resolve axios mocking errors using JEST and REACT

Have created unit test cases using axios mock approach and do see below console errors. Have tried many approaches but none resolved the problem. Very new to REACT/JEST community, but trying best to resolve this. Expectation: All test cases…
user12133234
  • 371
  • 2
  • 5
  • 15
0
votes
1 answer

It is possible to use a wildcard for the URL when mocking axios?

I would like to know if it is possible to mock certain URLs using wildcards, e.g. all URLs that start with /auth. Can I do something like /auth*?
Javier Guzmán
  • 1,014
  • 2
  • 13
  • 27
0
votes
0 answers

How can axios-mock-adapter return an object on GET request?

There's a block of code that uses axios-mock-adapter and returns an object via a GET request: mock.onGet('/api/auth').reply((config) => { const data = JSON.parse(config.data); const {email, password} = data; const user =…
yaserso
  • 2,638
  • 5
  • 41
  • 73
0
votes
1 answer

Axios Post Method to implement customized headers and with token value

I'm trying to write a Post method with Axios in NodeJS. I have following things to pass as param in post method url = http:/xyz/oauthToken header 'authorization: Basic kdbvkjhdkhdskhjkjkv='\ header 'cache-control:no-cache' header 'content-type:…
Fatma Zaman
  • 69
  • 1
  • 2
  • 10
0
votes
2 answers

React-Redux app testing action creator containing axios GET call

I am writing a react-redux app and in one of my action creators I am making an api request via axios Roughly, it looks something like this: import axios from 'axios' export function getStoredData(userInput) { . . . var url =…
1 2 3 4 5
6