-
Notifications
You must be signed in to change notification settings - Fork 2.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
change waitFor
brace style, switch interval
default
#10662
Conversation
|
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.
LGTM
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.
Yay for reducing test boilerplate!
Were you able to automate this with a codemod or editor tricks? If it was all by hand, we should try to get these changes merged sooner, so you don't have to keep rebasing.
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.
🎉🎉
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.
I'm gonna be the bad guy here 😜. Check out my comments and let me know what you think.
I'd also like to float the question: is this PR still relevant? We've had it open for some time now unmerged and wasn't sure if thats because it was forgotten or not.
@@ -5260,11 +5250,11 @@ describe("useSuspenseQuery", () => { | |||
}, | |||
}); | |||
|
|||
await waitFor(() => { | |||
await waitFor(() => |
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.
Any reason these needed to change? Perhaps I'm picky/selfish, but this seems like a change for the sake of change. I'd prefer to leave these alone for now.
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.
I'll be the bad guy and say I'm not sure I see much meaningful change in this file. It feels like change for the sake of change. Any chance we could revert this?
@@ -27,6 +32,9 @@ import { QueryResult } from "../../types/types"; | |||
import { useQuery } from "../useQuery"; | |||
import { useMutation } from "../useMutation"; | |||
|
|||
const waitFor: typeof _waitFor = (callback, options) => |
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.
I see enough interval: 50
overrides in here to think that this change doesn't make as big of an impact as normal. Could you perhaps rename this to waitForOne
and use that in places where interval: 1
is set? That way we can leave anything with interval: 50
to use the default waitFor
function without needing the override.
@@ -19,6 +19,9 @@ import { QueryResult } from "../../types/types"; | |||
|
|||
const IS_REACT_18 = React.version.startsWith("18"); | |||
|
|||
const waitFor: typeof _waitFor = (callback, options) => |
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.
Could we consider naming this waitForOne
and use that everywhere we use waitFor
with interval: 1
? That way its easier to use the built-in waitFor
without needing the override where necessary. Thoughts?
This was a follow-up PR to the prettier PR, so I guess some of the style changes you are seeing might be prettier-related - with prettier the extra braces mean more newlines and one-line statements became four-line statements, so this is an attempt to undo some of that bloat. I'm fine with either So yeah, still relevant, but something I'll probably have to redo after the prettier PR :) |
At this point, I guess this has lost relevance as the new testing style mostly works without |
do not merge before #10661 has been merged
This PR changes from
to
in a ton of places,
and in return replaced
with
We used
interval: 1
a lot more often than skipping the parameter, and like this, it makes it much more obvious where we still had the slower default. We might want to revisit those places.I've also highlighted some
waitFor
instances that just seem wrong, but I didn't change any runtime behaviour of the tests - that's for another PR.I've also dropped the method body braces where there was only one statement in
waitFor
, as that compacts the tests a bit.do not merge before #10661 has been merged