Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matching http request are passing #42

Closed
Tabris841 opened this issue Oct 15, 2019 · 7 comments · Fixed by #44
Closed

Matching http request are passing #42

Tabris841 opened this issue Oct 15, 2019 · 7 comments · Fixed by #44
Labels

Comments

@Tabris841
Copy link

Hi,

First of all i love the idea of the library. Great Job guys!!!. I wanted to include the the library in
my project, but i don't want to mock every request so i set MockConfig allowXHRPassthrough and allowFetchPassthrough to true. And the problem is every request
is passing even when there is matching route and when there is response then data-mocks
replace the response. Is that intended behaviour and can the requests be intercept when they match before sending(cause for example i want to mock and endpoint before is created)?

To Reproduce
Just create angular project the cli and add data-mock.
Set the allowXHRPassthrough and allowFetchPassthrough to true
Create some scenario(example:
{
url: /users/,
method: 'GET',
response: { some: 'good response' },
responseCode: 200
})
Make a http call to that scenario(example: ''http://localhost:3000/api/users')

@grug
Copy link
Owner

grug commented Nov 19, 2019

Hey @Tabris841 - two things!

  1. I'm so so so so sorry I didn't get back to you on this any sooner. I've been on leave with my newborn so I haven't had time to throw at data-mocks until now as I'm back in action!
  2. Thank you so much for bringing this issue up. I'll work on a fix for it this week :)

-Dave

@grug grug added the bug label Nov 19, 2019
@mpoelstra
Copy link

Just dropping by to inform you I have the same problem.

@grug
Copy link
Owner

grug commented Nov 21, 2019

I'm still planning on fixing this tomorrow :) Hopefully it'll be released then, too!

@LaserUnicorns
Copy link

Current workaround is to use XHRMock proxy directly after injectMocks

  injectMocks(scenarios, undefined, {
    // allowXHRPassthrough: true,
  });
  XHRMock.use(proxy);

@grug
Copy link
Owner

grug commented Nov 21, 2019

Sweet - a fix is in master and I've checked it out and it's good. I'll make a release now.

@grug
Copy link
Owner

grug commented Nov 21, 2019

Version 2.5.13 is out now and should make everything all good. Let me know if you have any other questions/problems :) Once again, so sorry for taking so long to getting this one sorted!

@mpoelstra
Copy link

Sweet! Works like a charm, thx! And don't be sorry, taking care for your newborn is far more important ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants