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

chore: migrate use of @testing-library/react-hooks #867

Merged
merged 15 commits into from
May 25, 2023

Conversation

fionnachan
Copy link
Member

@fionnachan fionnachan commented May 22, 2023

Summary

it's good practice to update the library to date esp because @testing-library/react-hooks fallbacks to react 17 instead of react 18

Note: waitForNextUpdate and waitForValueToChange are removed when renderHook was migrated to @testing-library/react and so there are more changes in the tests than a simple library migration / update

Steps to test

tests should work and pass as usual

@cla-bot cla-bot bot added the cla-signed label May 22, 2023
@vercel
Copy link

vercel bot commented May 22, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
arbitrum-token-bridge ✅ Ready (Inspect) Visit Preview May 25, 2023 2:25pm

@fionnachan fionnachan changed the title chore: replace @testing-library/react-hooks with /react chore: migrate @testing-library/react-hooks May 22, 2023
@fionnachan fionnachan changed the title chore: migrate @testing-library/react-hooks chore: migrate use of @testing-library/react-hooks May 22, 2023
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after moving to @testing-library/react i got some type errors so had to update the packages
FYI @testing-library/react-hooks did not support react 18 and was running on react 17

@@ -339,32 +310,31 @@ describe('useBalance', () => {
}
])
)
})
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertions shouldn't be wrapped in the same act function as it was previously

@@ -23,7 +23,7 @@ export function RetryableTxnsIncluder(): JSX.Element {
} = useAppState()

const fetchAndUpdateDepositStatus = useCallback(
async (depositTxId, depositAssetType) => {
async (depositTxId: string, depositAssetType: AssetType | string) => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@types/react & @types/react-dom v17 for some reason allow it to be of type any and won't throw an error but v18 will

Copy link
Contributor

@dewanshparashar dewanshparashar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, this removes the warnings we got during test:ci :)
Small comments were identified.

packages/arb-token-bridge-ui/src/hooks/useBalance.ts Outdated Show resolved Hide resolved
packages/arb-token-bridge-ui/src/hooks/__tests__/utils.ts Outdated Show resolved Hide resolved
chrstph-dvx
chrstph-dvx previously approved these changes May 25, 2023
Copy link
Contributor

@chrstph-dvx chrstph-dvx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

import { StaticJsonRpcProvider } from '@ethersproject/providers'
import { BigNumber } from 'ethers'
import { SWRConfig } from 'swr'
import { PropsWithChildren } from 'react'
import { MultiCaller } from '@arbitrum/sdk'
import { useBalance } from '../useBalance'

import { renderHookAsyncUseBalance } from './utils'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would still keep renderHookAsyncUseBalance co-located in useBalance file.
My rationale: If there are 5 more tests like useBalance in the future.. we should have their specific renderHookAsync calls in their own files rather than bloating generic utils

Copy link
Contributor

@dewanshparashar dewanshparashar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fionnachan fionnachan merged commit f474442 into master May 25, 2023
11 checks passed
@fionnachan fionnachan deleted the testing-library-react branch May 25, 2023 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace @testing-library/react-hooks with @testing-library/react
3 participants