axios-mock-adapter
axios-mock-adapter copied to clipboard
Axios adapter that allows to easily mock requests
When adding multiple different handlers, last one overrides previous ones: ``` // this one is overridden httClientMock.onPost('/table', expect.objectContaining({ sortModel: [] })) .reply(200, mockTableData); // this one is the only one...
auto-import in vscode wants `import MockAdapter from 'axios-mock-adapter/types';` this is not correct/doesn't work instead it needs to be `'axios-mock-adapter';` obviously I'm hand correcting it, but I suspect this is a...
``` "axios": "0.21.1", "axios-mock-adapter": "1.19.0" ``` **Issue:** Adapter can't match URL if it contains part of base URL **Example:** Base URL is `/app` and url is `/appliance` mock won't match...
When using a regex expression, requests don't get caught by the adapter in some cases This works : ``` const axios = axios.create({ baseURL: 'https://apiurl.com' }) axios.get('/foo/123').then(function (data) { console.log(data)...
``` axios .post(url, payload) .then((res) => { if (res.error) { throw res.error; // **_THIS PART, WHERE WE HAVE ERROR AS IN RESPONSE_** } const someVar= res.data; }) .catch((error) => {...
I mean something like this: ``` mock.onPost('/any').reply(201, null, { delay: 2000 }) ```
I've run into a case where I needed to customize axio's `paramsSerializer` to change the default handling of array serialization. It would be super if we could test for proper...
## Domain knowlage With last update there is a way to make `axios-mock-adapter` to throw an error when unhanded request happen. ``` const mock = new MockAdapter(axios, { onNoMatch: "throwException"...
I have a component that waits until some data from a resource. I'm using React suspense to show the loading screen as until it gets the response. When testing, even...
Hi there! First of all - thank you for a great tool! ) I am using `MockAdapter` in storybook environment during development phase. I have a form where I am...