You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using `render()`, an in-memory router is used, which will react to navigations with `useNavigate()` or interations with `Link` components. If your component relies on the URL, you can define the initial state in `initialRouterConfig`. You can access the current router state by referencing the returned `router` class, as well as navigate programmatically with `router.navigate()`.
@@ -221,3 +237,55 @@ import {render, screen, userEvent} from "sentry-test/reactTestingLibrary";
221
237
render(<Example />);
222
238
userEvent.type(screen.getByLabelText("Search by name"), "sentry");
223
239
```
240
+
241
+
## Testing hooks with providers
242
+
243
+
Use `renderHookWithProviders()` to test hooks with the same built-in providers as `render()` (organization, theme, query client, and an in-memory router). It returns the regular `renderHook` result plus a `router` helper you can use to inspect location and navigate.
244
+
245
+
Set the initial URL and define route patterns via `initialRouterConfig` (use `route` for a single route or `routes` for multiple):
0 commit comments