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

fix: api test inconsistencies #1360

Merged
merged 1 commit into from
Jun 10, 2022
Merged

fix: api test inconsistencies #1360

merged 1 commit into from
Jun 10, 2022

Conversation

tlgimenes
Copy link
Contributor

What's the purpose of this pull request?

Testing @faststore/api has an issue where the mocked fetch is called less than the expected amount of times, making some tests break.

This is because we store our clients on the GraphQL context. Since these clients use Dataloader and we were not recycling them on each tests, some requests were being cached and thus, the mocked fetch was called less than the right amount of times.

How it works?

This PR creates a runner function that re-creates the GraphQL context before each test so we have a more similar environment to the one we use in production, where a new context is created for each request

@tlgimenes tlgimenes added bug Something isn't working store-api labels Jun 10, 2022
@tlgimenes tlgimenes requested a review from a team as a code owner June 10, 2022 15:20
@vercel
Copy link

vercel bot commented Jun 10, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
faststore ✅ Ready (Inspect) Visit Preview Jun 10, 2022 at 3:20PM (UTC)

@codesandbox-ci
Copy link

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 ab03a1e:

Sandbox Source
Store UI Typescript Configuration

Copy link
Member

@victorhmp victorhmp left a comment

Choose a reason for hiding this comment

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

Nice! 😄

@tlgimenes tlgimenes merged commit 5a02e72 into main Jun 10, 2022
@tlgimenes tlgimenes deleted the fix/test-inconsistency branch June 10, 2022 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants