-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
[UI v2] exercise: Adds test for variables hook that focuses on react query and query caching and invalidation #16158
Conversation
03a60ea
to
475a68f
Compare
b7fb258
to
3d0d6b8
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.
exporting these queries so we can access the cache data via queryKey
programmatically
Hi, team, great discussions around the data fetch/cache layer. I followed some of the discussions and am inspired to create a tool for generating some of the code discussed:
The goal is to have an easy-to-use API and write minimal boilerplate code. Would the team be interested in using it? BTW,
Would the below work better?
By adding to ui-v2/tsconfig.app.json: "paths": {
"@/*": ["./src/*"],
"@tests/*": ["./tests/*"] // Or "@mocks/*": ["./tests/mocks/*"]
}, |
I think from a dev-ex perspective, as a developer, I just want to import the necessary utilities to help expedite my test creation. So I think something like:
|
3d0d6b8
to
e232e62
Compare
…query and query caching and invalidation
e232e62
to
377fcc5
Compare
This PR goes over the exercise of what it may look like adding tests that focuses on our react query modules.
This test covers the integration between how data is fetched, stored, mutated, and fetched again when using
@tanstack/query
for server data management.The main test is to ensure our query keys are being properly invalidated and re-fetching data from the server. This should help build confidence when building query modules for different data sources without being dependent on building and testing with UI
A good blog on how to write tests for react query: https://tkdodo.eu/blog/testing-react-query
variables.test.tsx
(which may get confusing with our other file ofvariables.test.tx
that tests the route and UX level). These tests our query hooks and its mutations.💡 Future considerations when going through this exercise:
msw
, there is a overlap with https://github.com/PrefectHQ/prefect/blob/main/ui-v2/tests/mocks/node.ts. Maybe we should create an alias, or centralize some type of test utils folder for this. It seems odd to call the server using../../test/mocks/node
.Checklist
<link to issue>
"mint.json
.Related to #15512