redwoodjs / redwoodjs-com-archive

Public website for RedwoodJS
https://redwoodjs.com
129 stars 156 forks source link

Document why currentUser might be null after mocking #927

Closed callingmedic911 closed 2 years ago

callingmedic911 commented 2 years ago

Closes https://github.com/redwoodjs/redwood/issues/3912.

cannikin commented 2 years ago

What do you think about this update @jtoar? I'm still not 100% sure I understand the problem: I haven't run into this issue, but everyone else says it's potentially confusing!

jtoar commented 2 years ago

@cannikin I agree that it seems like if you use waitFor or an async matcher (not sure if that's the right term—queryByRole, findByText, etc), this just takes care of itself.

But maybe where the confusion occurs is: it doesn't seem like we say that waitFor and/or an async matcher is necessary and if it is (seems like it is), why. Right now we say we use waitFor because queryByRole isn't async, but we don't explain why being async matters. So maybe I can work @callingmedic911's new paragraph into the previous one or just add a callout that says "hey, we're using waitFor and/or an async matcher because we need to wait for an update because currentUser is actually null in the first render..."