Skip to content
Source
Sign inSign up
TanStack/router

test(router): add waitFor for page navigation link/optional-path-params #5741

Mergedbirkskyum(GitHub profile, opens in a new tab)merged 4 commits intomain fromrefs/pull/5741/headmerged by birkskyum(GitHub profile, opens in a new tab)

Showing 4 changed files with 30 additions and 10 deletions (loading 1).

x
0 of 4 viewed, 4 left
4 additions and 0 deletionspackages/react-router/tests/link.test.tsxModified
View file
@@ -360,6 +360,10 @@
// navigate to /?foo=bar
await act(() => fireEvent.click(indexFooBarLink))
​
+ await waitFor(() => {
+ expect(indexFooBarLink).toHaveClass('active')
+ })
+​
expect(indexExactLink).toHaveClass('inactive')
expect(indexExactLink).not.toHaveClass('active')
expect(indexExactLink).toHaveAttribute('href', '/')
22 additions and 10 deletionspackages/react-router/tests/optional-path-params.test.tsxModified
View file
@@ -1,6 +1,13 @@
import { afterEach, describe, expect, it, vi } from 'vitest'
-import { act, cleanup, fireEvent, render, screen } from '@testing-library/react'
import {
+ act,
+ cleanup,
+ fireEvent,
+ render,
+ screen,
+ waitFor,
+} from '@testing-library/react'