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

Mocking useLocation in web/src/components tests #5190

Closed
jtoar opened this issue Apr 15, 2022 · 4 comments · Fixed by #6791
Closed

Mocking useLocation in web/src/components tests #5190

jtoar opened this issue Apr 15, 2022 · 4 comments · Fixed by #6791

Comments

@jtoar
Copy link
Contributor

jtoar commented Apr 15, 2022

Edit: seem Kris Coulson's comment: #5190 (comment)


Currently it doesn't seem like it's possible to mock useLocation in components that use it. See https://discord.com/channels/679514959968993311/964542735614881862

@jtoar jtoar added this to Triage Apr 15, 2022
@jtoar jtoar moved this from Needs triage to Todo in Triage Apr 15, 2022
@jtoar jtoar moved this to Needs triage in Triage Apr 15, 2022
@KrisCoulson
Copy link
Contributor

@jtoar this is how we mock the location in Teamstream

import { LocationProvider } from '@redwoodjs/router'

render(
<LocationProvider location={{ pathname: '', search: '?cancelled=true' }}>
   <Component />
</LocationProvider>
)

@jtoar
Copy link
Contributor Author

jtoar commented Apr 16, 2022

@KrisCoulson thanks! That seems super obvious now. Let's keep this open as a reminder to add this to the docs.

@jtoar jtoar added this to Main May 5, 2022
@jtoar jtoar moved this to Backlog in Main May 5, 2022
@jtoar jtoar removed this from Triage May 8, 2022
@MagnusHJensen
Copy link

A discord link like that, which doesn't actually work is not a very reliable way to indicate a reference 😅

@bigbuckalex
Copy link
Contributor

I took a shot at adding this to the docs. I'm not sure if there is a better place for it or if anyone would want to expand on this. #6791

@jtoar jtoar linked a pull request Nov 4, 2022 that will close this issue
@jtoar jtoar closed this as completed Nov 4, 2022
Repository owner moved this from Backlog to Done in Main Nov 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants