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

refactor: [M3-7800] - Clean up new QueryClient() pattern in unit tests #10217

Conversation

bnussman-akamai
Copy link
Member

Description 📝

  • Cleans up unit test by removing unneeded new QueryClient() instances 🧹
  • For context, we use to do new QueryClient() in our unit test because we were having issues with unit tests sharing the same React Query QueryClient and cache. It was causing flakiness. Today, wrapWithTheme create a new QueryClient each time it is called and Vitest ensures each test runs in isolation. We shouldn't need to do new QueryClient() in our unit test because they are isolated by default 📙

How to test 🧪

Verification steps

  • Run yarn test locally 💻
  • Verify GitHub Actions passes ✅

As an Author I have considered 🤔

  • 👀 Doing a self review
  • ❔ Our contribution guidelines
  • 🤏 Splitting feature into small PRs
  • ➕ Adding a changeset
  • 🧪 Providing/Improving test coverage
  • 🔐 Removing all sensitive information from the code and PR description
  • 🚩 Using a feature flag to protect the release
  • 👣 Providing comprehensive reproduction steps
  • 📑 Providing or updating our documentation
  • 🕛 Scheduling a pair reviewing session
  • 📱 Providing mobile support
  • ♿ Providing accessibility support

@bnussman-akamai bnussman-akamai added the Unit tests Improves unit test coverage label Feb 22, 2024
@bnussman-akamai bnussman-akamai self-assigned this Feb 22, 2024
@bnussman-akamai bnussman-akamai requested a review from a team as a code owner February 22, 2024 01:21
@bnussman-akamai bnussman-akamai requested review from jdamore-linode and carrillo-erik and removed request for a team February 22, 2024 01:21
Copy link

github-actions bot commented Feb 22, 2024

Coverage Report:
Base Coverage: 81.32%
Current Coverage: 81.31%

Copy link
Contributor

@hkhalil-akamai hkhalil-akamai left a comment

Choose a reason for hiding this comment

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

This is great cleanup, looks good with all unit tests passing. Approved pending conflicts.

Comment on lines -47 to -51
setLogger({
log: () => {},
warn: () => {},
error: () => {},
});
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it was a way to hide some console warning/errors, but I don't think we need to do it anymore. I don't see any React Query specific errors in our test logs

@bnussman-akamai bnussman-akamai added the Add'tl Approval Needed Waiting on another approval! label Feb 23, 2024
Copy link
Contributor

@abailly-akamai abailly-akamai left a comment

Choose a reason for hiding this comment

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

Wholesome, thank you!

@bnussman-akamai bnussman-akamai added Approved Multiple approvals and ready to merge! and removed Add'tl Approval Needed Waiting on another approval! labels Feb 26, 2024
@bnussman-akamai bnussman-akamai merged commit ca52738 into linode:develop Feb 26, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Approved Multiple approvals and ready to merge! Clean Up Unit tests Improves unit test coverage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants