morsdyce/mimic

Is there a way to bypass the default mocking?

facundocabrera opened this issue · 8 comments

Hey everyone,

I'm dealing with a project using a really old version of the project (v0.3.3) and I need to bypass the default mocking.

Is there a boolean field or a regex to say to bsdm "please ignore this request"?

Thanks in advance

Hi @dendril

That's a really old version :)
If i'm not mistaken, that version should be the material UI version, in which case you can open the UI via the toggle on lower right side and open the scenario that holds the mock you wish to cancel.

Beside each mock you should see a toggle button to turn it on/off.
You should also be able to disable the entire scenario by clicking the power button at the bottom of the scenario but i'm not sure if that feature was available then.

If you are looking for a programmatic way you can look at our public API file for that version here:
https://github.com/500tech/mimic/blob/v0.3.3/lib/api/index.js

You can use the toggleMockedRequest method to toggle a request active state by providing a scenario id and a mock id.

you should be able to get these ids from mockedRequests and scenarios properties on the API object.

Thanks

Thanks a lot for you time, I really appreciate your fast response.

Last question, I'm seeing an error when enabling mimic (testing latest now) and using Authorization header. For some reason the code which is mocking the fetch API is losing the Authorization header in my requests.

Ideas?

I'm not sure I understand what you mean by losing the Authorization header.

When mocking a request with Mimic we currently do not take request headers in account to match mocks, to avoid issues with various http clients and special headers that only apply for working with the real servers (like authorization).

The mock response should return the response headers which you can edit from the Response Headers tab when editing your mock.

If you think you have some use case we should support and do not cover currently I'd love for a small example we can reproduce and fix.

Thanks!

Now I understand how this works. I was assuming the following if I don't have a mock defined, mimic should forward the request to the destination server. Right now I'm seeing a partial behavior, where mimic forward the request, but without custom headers. Is this correct?

If you don't have a mock defined mimic forwards the request without interfering at all except for reading the response when it's ready so the request should be sent normally with everything.

If it forwards the request without some headers it should be a bug in our interceptor library called xhook which I also maintain.

If this is the case I would love for an example I could examine

I'll investigate more because I don't know why it's losing the header. I'm sure about this because if I turn off mimic, the request just works, but when I enable it, I'm getting a 400 and when I check the request in the devTools the Authorization header is missing.

Hi @dendril any updates on it? Did you get it working?