-
Notifications
You must be signed in to change notification settings - Fork 271
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
testing-library can't find i18next Trans texts #964
Comments
Hi @davydspotnana , this issue is currently being adressed (see #937 for more information). You can refer to this comment #937 (comment) for a workaround by mocking the trans component. Hope this helps ! |
Thanks the help @pierrezimmermannbam, will mark as duplicate. |
@pierrezimmermannbam I am an author of two these issue ) I don think that this is duplicate (@AugustinLF please reopen it) I don't want to mock a With a mock I can't:
<Trans values={{cars: 2}}>{`{{cars}} car`}`</Trans>
// getByText('2 cars')
// getByText('1 car')
<Trans values={{ NON__CAR_NAME: 2 }}>{`{{cars}} car`}`</Trans>
// getByText('2 cars') // not found |
@retyui The root cause is the same in both issues. RNTL can only detect text directly inside We agree that mocking is not a long term solution, we're still trying to find a real fix, there's some progress in #967 but it's a non trivial issue. |
Describe the bug
I'm using a
<Trans/>
component fromreact-i18next
module to translate complex react elements (without mocking it)It works well in React Native runtime:
debug()
text that I'm trying to find existsExpected behavior
Steps to Reproduce
Screenshots
Full code you find here https://github.com/retyui/testing-library-and-i18next-issue
Versions
The text was updated successfully, but these errors were encountered: