get request parameter from axios mock in test

1.3k Views Asked by At

I create dynamically a request string in my react application, passing it to axios.get to request some data from REST interface. In my react test, I mock axios with

axios.get.mockResolvedValue({
  data: {
    list: [
      { name: "Name 1", id: 0 },
      { name: "Name 1", id: 0 }
      etc
    ]
  }
})

Which gives me always a static result - which is fine. But now, I also want to test depending on the dynamically created search term, so the question is: How do I get the request string/parameter from axios.get function in my mock?

0

There are 0 best solutions below