Open resetko opened 3 years ago
This issue originated with the axis0.21.1 release for me. Currently I'm using a workaround with patch-package with the change at src/handle_request.js:
@resetko The URL is overwritten in the below if block: https://github.com/ctimmerm/axios-mock-adapter/blob/d60c55b9ebbc7556970461460e66ae253e9d6599/src/handle_request.js#L39-L45
The above code checks if the base URL and the underlying URL match, if they do, it replaces it with just the URL and removes the base URL. Not sure why we do this.
If we comment the if clause out, the above scenario works with and without a base URL and all the tests pass (there is a comment specifying that this if clause is not tested).
Another work around is if we add the whole URL along with the base URL, your scenario works:
instance
.get("/app/appliance")
.then((response) => console.log("/appliance works", response.data))
.catch((e) => console.log("/appliance error"));
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 😞above code will output
Link for quick check: https://codesandbox.io/s/lucid-goodall-0qu35?file=/src/index.js
Is it a known issue with known workaround? 🤔