-
-
Notifications
You must be signed in to change notification settings - Fork 735
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
Do not disable mocks during recording #1747
Comments
Hey @dziamid thanks for opening this issue. I think I'm not understanding some part of what you're asking for. How are you suggesting using the recorder in step one, and what makes that not possible today? I don't use the recorder much myself, so please bear with me! |
@paulmelnikow thanks for your reply. Generally speaking, I'm proposing to rethink this (from readme):
We should not disable mocks during recording. They are very helpful together with recording! With the help of mocks, we can guide the system to behave in the direction we want and hence record a specific sequence of requests. Let me elaborate with an example.
With the current implementation of the recorder, you are forced to ensure that all the above requirements are met, then do the recording. From my experience, this is highly impractical or not even possible. E.g. that fact that someone eligible for a special offer can be outside of your control (think 3rd party services). But wait, we can use the mocks to our advantage! If we allow nock to use mocks when available and fallback to real network requests then developers can:
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We try to do our best, but nock is maintained by volunteers and there is only so much we can do at a time. Thank you for your contributions. |
This would indeed be useful. |
Context
Recording requests in complex flows that issue multiple requests that depend on one another is a pain. Essentially as soon as the recorder is enabled, the first real HTTP request that fails or returns undesired response would take you in the wrong direction. It is always easy or possible to simulate a real HTTP request with the desired outcome in the test environment. The examples of such cases are:
With an option to enable mocks during the recording you can record any complex flow with one failing request at a time.
For example, suppose there are no mocks yet defined. Then here is the proposed flow to write a test case:
Alternatives
Currently, the only alternative I see is to write small isolated scripts that simulate a specific application state and record from there.
Has the feature been requested before?
Nope
If the feature request is accepted, would you be willing to submit a PR?
Absolutely, with some guidance
The text was updated successfully, but these errors were encountered: