-
Notifications
You must be signed in to change notification settings - Fork 63
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
chore(api): Make tests more stable by mocking VTEX API calls #1200
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit a8033f9:
|
304c173
to
1ce2b3b
Compare
1ce2b3b
to
4e75bc7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a future PR, we need to work towards removing these hard-coded mocked api responses too and use snapshots instead
But how would we use snapshots for the API responses? We would have the same problem we currently have, right? If something changes in the In the way it is with these mocked API responses, we're testing all the layers apart from the real VTEX's APIs. We're testing the schema, the resolvers, and the logic inside the clients. |
What's the purpose of this pull request?
Make all tests from
@faststore/api
more stable, by not relying on dynamic data.How it works?
With this change, no actual HTTP request will be made when the tests suites are executed. Instead, a mocked version of the
fetchAPI
function will be called by each of our clients. Then the function calls are evaluated usingjest.mock
utilities.This should make it so tests don't break if something changes in the account from which we get data (
storeframework
).How to test it?
Run
yarn test
insidepackages/api
.base.store
Deploy PreviewNo need, nothing changed in the actual package's implementation :)