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
> a`goto` prop can be passed to customize the `navigate` behavior during tests
358
+
> A`goto` prop can be passed to customize the `navigate` behavior during tests
359
359
360
360
```tsx title="src/components/button.spec.tsx"
361
361
import { $ } from'@builder.io/qwik';
@@ -383,6 +383,53 @@ test('should render the button and navigate', async () => {
383
383
});
384
384
```
385
385
386
+
> If you are using `routeLoader$`s in a Qwik Component that you want to test, you can provide a `loaders` prop to mock the data returned by the loaders
test('should render footer with product name', async () => {
417
+
const { screen, render } =awaitcreateDOM();
418
+
const loadersMock = [
419
+
{
420
+
loader: useProductData,
421
+
data: { product: { name: 'Test Product' } },
422
+
},
423
+
];
424
+
awaitrender(
425
+
<QwikCityMockProviderloaders={loadersMock}>
426
+
<Footer />
427
+
</QwikCityMockProvider>,
428
+
);
429
+
expect(screen.innerHTML).toMatchSnapshot();
430
+
});
431
+
```
432
+
386
433
## `<RouterOutlet>`
387
434
388
435
The `RouterOutlet` component is responsible for rendering the matched route at a given moment, it internally uses the [`useContent()`](/docs/(qwikcity)/api/index.mdx#usecontent) to render the current page, as well as all of the nested layouts.
0 commit comments