You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the code below, the "mock.onGet without trailing slash" test fails.
importaxiosfrom'axios';importMockAdapterfrom'axios-mock-adapter'classFoo{constructor(endpoint){this.axios=axios.create({baseURL: endpoint});}getFoos(){returnthis.axios.get();}getFooBars(){returnthis.axios.get("bar");}}describe("Foo",()=>{constENDPOINT="http://test.com/bogus"letmock;letsubject;beforeEach(()=>{mock=newMockAdapter(axios);subject=newFoo(ENDPOINT);})afterEach(()=>{mock.restore();});// ----- This test fails :( ---------------------it("mock.onGet without trailing slash",()=>{mock.onGet(ENDPOINT).reply(200,{});returnsubject.getFoos();});// ----- This one passes O_o --------------------it("mock.onGet with trailing slash",()=>{mock.onGet(`${ENDPOINT}/`).reply(200,{});returnsubject.getFoos();})});
What is expected?
I expect the "mock.onGet without trailing slash" test to pass.
I'm not sure if the "mock.onGet with trailing slash" should pass or not... I would think not...
What is causing this?
The current implementation for combineUrls() leaves a trailing slash when url is empty. (See utils.js for more info).
I would expect this to be consistent with the way axios combines URLs. Maybe we can even import this method?
What am I willing to do about it?
I can create a PR that updates the implementation of combineUrls(), if it is agreed that this is an issue.
The text was updated successfully, but these errors were encountered:
I am having a similar issue. For me even adding a trailing slash does not work. However if I put the url as regular expresion with /* at the end it works.
@bcdbuddy I am not a maintainer but in my opinion because we can do it with regex does not mean is enough for closing the issue. I mean, it should work without regex, shouldn't it?
I don't think so. I am assuming it is only doing string comparison so if there is a trailing slash or not that can cause a mismatch. Simple enough. As long as there is one way of achieving the expected result without any change on this lib I think we should go for that option.
In any case, this repo seems dead
What is the current behavior?
In the code below, the "mock.onGet without trailing slash" test fails.
What is expected?
What is causing this?
The current implementation for
combineUrls()
leaves a trailing slash whenurl
is empty. (See utils.js for more info).I would expect this to be consistent with the way axios combines URLs. Maybe we can even import this method?
What am I willing to do about it?
I can create a PR that updates the implementation of
combineUrls()
, if it is agreed that this is an issue.The text was updated successfully, but these errors were encountered: