-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Update @testing-library/react from 13.3.0 to 16.0.1; Fixes #4685 #4686
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
Changes from all commits
a531f50
97f96ad
5255770
f861244
0536468
ef84607
23a1c3f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,8 +56,9 @@ | |
"@phryneas/ts-version": "^1.0.2", | ||
"@size-limit/file": "^11.0.1", | ||
"@size-limit/webpack": "^11.0.1", | ||
"@testing-library/react": "^13.3.0", | ||
"@testing-library/user-event": "^13.1.5", | ||
"@testing-library/dom": "^10.4.0", | ||
"@testing-library/react": "^16.0.1", | ||
"@testing-library/user-event": "^14.5.2", | ||
Comment on lines
-59
to
+61
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated Since the version v16.0.0, Updated |
||
"@types/babel__core": "^7.20.5", | ||
"@types/babel__helper-module-imports": "^7.18.3", | ||
"@types/json-stringify-safe": "^5.0.0", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ import { | |
actionsReducer, | ||
setupApiStore, | ||
useRenderCounter, | ||
waitForFakeTimer, | ||
waitMs, | ||
withProvider, | ||
} from '@internal/tests/utils/helpers' | ||
|
@@ -47,7 +48,7 @@ interface Item { | |
|
||
const api = createApi({ | ||
baseQuery: async (arg: any) => { | ||
await waitMs(150) | ||
await waitForFakeTimer(150) | ||
if (arg?.body && 'amount' in arg.body) { | ||
amount += 1 | ||
} | ||
|
@@ -465,7 +466,6 @@ describe('hooks tests', () => { | |
<div> | ||
<button | ||
onClick={() => { | ||
console.log('Refetching') | ||
refetch() | ||
}} | ||
> | ||
|
@@ -915,7 +915,7 @@ describe('hooks tests', () => { | |
resPromise = refetch() | ||
}) | ||
expect(resPromise).toBeInstanceOf(Promise) | ||
const res = await resPromise | ||
const res = await act(() => resPromise) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed this warning:
|
||
expect(res.data!.amount).toBeGreaterThan(originalAmount) | ||
}) | ||
|
||
|
@@ -1095,15 +1095,15 @@ describe('hooks tests', () => { | |
// Allow at least three state effects to hit. | ||
// Trying to see if any [true, false, true] occurs. | ||
await act(async () => { | ||
await waitMs(1) | ||
await waitForFakeTimer(150) | ||
}) | ||
|
||
await act(async () => { | ||
await waitMs(1) | ||
await waitForFakeTimer(150) | ||
}) | ||
|
||
await act(async () => { | ||
await waitMs(1) | ||
await waitForFakeTimer(150) | ||
}) | ||
|
||
// Find if at any time the isLoading state has reverted | ||
|
@@ -1864,7 +1864,8 @@ describe('hooks tests', () => { | |
expect(screen.getByTestId('isFetching').textContent).toBe('false'), | ||
) | ||
|
||
userEvent.hover(screen.getByTestId('highPriority')) | ||
await userEvent.hover(screen.getByTestId('highPriority')) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since Release v14.0.0 · testing-library/user-event |
||
|
||
expect( | ||
api.endpoints.getUser.select(USER_ID)(storeRef.store.getState() as any), | ||
).toEqual({ | ||
|
@@ -2001,7 +2002,7 @@ describe('hooks tests', () => { | |
await waitMs(400) | ||
|
||
// This should run the query being that we're past the threshold | ||
userEvent.hover(screen.getByTestId('lowPriority')) | ||
await userEvent.hover(screen.getByTestId('lowPriority')) | ||
expect( | ||
api.endpoints.getUser.select(USER_ID)(storeRef.store.getState() as any), | ||
).toEqual({ | ||
|
@@ -2101,7 +2102,7 @@ describe('hooks tests', () => { | |
|
||
render(<User />, { wrapper: storeRef.wrapper }) | ||
|
||
userEvent.hover(screen.getByTestId('lowPriority')) | ||
await userEvent.hover(screen.getByTestId('lowPriority')) | ||
|
||
expect( | ||
api.endpoints.getUser.select(USER_ID)(storeRef.store.getState() as any), | ||
|
@@ -2993,6 +2994,11 @@ describe('skip behavior', () => { | |
await act(async () => { | ||
rerender([1]) | ||
}) | ||
|
||
await act(async () => { | ||
await waitForFakeTimer(150) | ||
}) | ||
|
||
expect(result.current).toMatchObject({ status: QueryStatus.fulfilled }) | ||
await waitMs(1) | ||
expect(getSubscriptionCount('getUser(1)')).toBe(1) | ||
|
@@ -3030,6 +3036,11 @@ describe('skip behavior', () => { | |
await act(async () => { | ||
rerender([1]) | ||
}) | ||
|
||
await act(async () => { | ||
await waitForFakeTimer(150) | ||
}) | ||
|
||
expect(result.current).toMatchObject({ status: QueryStatus.fulfilled }) | ||
await waitMs(1) | ||
expect(getSubscriptionCount('getUser(1)')).toBe(1) | ||
|
@@ -3059,7 +3070,7 @@ describe('skip behavior', () => { | |
) | ||
|
||
await act(async () => { | ||
await waitMs(1) | ||
await waitForFakeTimer(150) | ||
}) | ||
|
||
// Normal fulfilled result, with both `data` and `currentData` | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,12 +71,12 @@ describe('refetchOnFocus tests', () => { | |
expect(screen.getByTestId('amount').textContent).toBe('1'), | ||
) | ||
|
||
fireEvent.focus(window) | ||
|
||
await act(async () => { | ||
fireEvent.focus(window) | ||
await delay(150) | ||
}) | ||
|
||
await delay(150) | ||
|
||
await waitFor(() => | ||
expect(screen.getByTestId('amount').textContent).toBe('2'), | ||
) | ||
|
@@ -111,9 +111,7 @@ describe('refetchOnFocus tests', () => { | |
expect(screen.getByTestId('amount').textContent).toBe('1'), | ||
) | ||
|
||
act(() => { | ||
fireEvent.focus(window) | ||
}) | ||
fireEvent.focus(window) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fireEvent is already wrapped in the act function: Common mistakes with React Testing Library |
||
|
||
await delay(150) | ||
|
||
|
@@ -165,9 +163,7 @@ describe('refetchOnFocus tests', () => { | |
expect(screen.getByTestId('amount').textContent).toBe('1'), | ||
) | ||
|
||
act(() => { | ||
fireEvent.focus(window) | ||
}) | ||
fireEvent.focus(window) | ||
expect(screen.getByTestId('isLoading').textContent).toBe('false') | ||
await waitFor(() => | ||
expect(screen.getByTestId('isFetching').textContent).toBe('true'), | ||
|
@@ -213,9 +209,7 @@ describe('refetchOnFocus tests', () => { | |
|
||
expect(getIncrementedAmountState()).not.toBeUndefined() | ||
|
||
await act(async () => { | ||
fireEvent.focus(window) | ||
}) | ||
fireEvent.focus(window) | ||
|
||
await delay(1) | ||
expect(getIncrementedAmountState()).toBeUndefined() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly, I didn’t get how to run tests in examples, and how to check if everything is OK.
When I run
yarn test
in the master branch, the tests run only for the following packages:@reduxjs/rtk-codemods
@rtk-query/codegen-openapi
@rtk-query/graphql-request-base-query
@reduxjs/toolkit
And when I go to
examples/query/react/basic
and runnpm test
there, I get the following error:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That should be fixed by #4603.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I correct something in this regard in the current pull request? Do you wanna merge #4603 first?