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
During development I am using stubRequest to return mock data for api endpoints that I know are incomplete.
Problem
On urls where there is no stub request to intercept the fetch, the fetch still never goes through - almost like moxios is catching EVERYTHING that goes through axios and not just the urls that match one of the stub requests.
Question
How can I have SOME fetches (which match a stubRequest) return mock data while allowing other fetches (which don't match any stub requests) return real data?
code
moxios.install();
const stubs = {};
//todo: make top three expressions pull from constants @jkr
stubs["^navigationMock"] = navigationMock;
stubs["^ancillaryMock"] = ancillaryMock;
stubs["^pageMock"] = pageMock;
stubs[constants.EVENT_CALENDAR_HREF] = eventCalendarMock;
stubs[constants.STYLE_GUIDE_HREF] = styleGuideMock;
for (const key in stubs) {
const re = new RegExp(key);
const mock = stubs[key];
// console.log(key, re, stubs[key])
moxios.stubRequest(re, {
status: 200,
response: mock
});
}
// console.log(moxios);
axios.create();
The text was updated successfully, but these errors were encountered:
jacksonkr
changed the title
Mix is real requests with mock requests ?
Mix real requests with mock requests ?
May 23, 2020
Scenario
During development I am using
stubRequest
to return mock data for api endpoints that I know are incomplete.Problem
On urls where there is no stub request to intercept the fetch, the fetch still never goes through - almost like moxios is catching EVERYTHING that goes through axios and not just the urls that match one of the stub requests.
Question
How can I have SOME fetches (which match a stubRequest) return mock data while allowing other fetches (which don't match any stub requests) return real data?
code
The text was updated successfully, but these errors were encountered: