Skip to content

Add support for capturing requests and responses for test data generation #341

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

Merged
merged 2 commits into from
Sep 7, 2023

Conversation

kwalker3690
Copy link

@kwalker3690 kwalker3690 commented Sep 6, 2023

This PR adds support for capturing requests and responses made through redux-query, for use as test data. The capturing will only occur if the cookie amp_store_requests_for_test_data is set to true. If that cookie is enabled, two functions are made available on the window:
getRequestsForTestData - returns the object including rest and gql requests and their responses
clearRequestsForTestData - resets the request object to be empty, in case the user wants to isolate request capturing to one area of the app.

Loom explanation of the bigger picture: https://www.loom.com/share/c20ca7a364244578bb742d687469a1d5

};
};

const cookieName = 'amp_store_requests_for_test_data';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

given this is a public package on NPM, do you think there is value in adding this in a configurable way? perhaps more broadly scoped cookie name at the very least?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'll change the 'amp' prefix!

Copy link
Contributor

@kelsonpw kelsonpw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Definitely useful, just one concern about re-usability for non amplitude users of this package

@kwalker3690 kwalker3690 merged commit ab94c45 into master Sep 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants