Closed mrousavy closed 2 months ago
@mrousavy it's seems that you have more complicated setup that RN 0.74 from template. The error mentions some getInspectorDataForViewAtPoint
function related to DevTools.
Does it happens also on RN straight from CLI? If no please post minimal repro.
BTW you dev deps mentions: "react-native": "0.73.0",
not 0.74
@mrousavy no worry with minimal repro, I've been able to reproduce it locally.
Findigs:
Modal
imported from react-native
. Trying to render it, even under React Test Renderer, throws:
Modal
(and other basic host components like View
, etc) it at the beginning of every render to get it's host component name, therefore all renders fail. If I disable it then it works fine. @pierrezimmermannbam maybe it's time to ditch detectHostComponents
in favour of just hardcoding component names & having our own internal tests that the name are still valid.
It was supposed to allow use to "automatically" adapt to RN changes but it causes some complex issue from time to time, as well make all user tests run slower. Wdyt?
Reported upsteam to RN as https://github.com/facebook/react-native/issues/43678
@mdjastrzebski I don't know, this issue for instance is not caused directly by the fact that we detect host names so I don't really understand your point that it causes complex issues? I like the fact that it detects early any config issue, it allows to tell sooner when users open issues wether it's a problem in their tests or in their setup / a compat issue with RN. Regarding the fact that it makes tests slower that's a valid point, I think I tested that, I don't remember exactly but I believe i found the difference to be negligible but we could run a new benchmark to make sure of that. We could also get rid of the line in the error message that says " Trying to detect host component names triggered the following error:" because it doesn't give any explanation and is rather confusing
/Users/runner/work/react-native-echarts/react-native-echarts/node_modules/react-native/src/private/specs/components/DebuggingOverlayNativeComponent.js: Unsupported param type for method "highlightTraceUpdates", param "updates". Found $ReadOnlyArray
There seems to be an issue with your configuration that prevents React Native Testing Library from working correctly.
Please check if you are using compatible versions of React Native and React Native Testing Library.
492 | const RNGHChart = gestureHandlerRootHOC(Chart);
493 | const gesture = jest.fn();
> 494 | render(
| ^
495 | <RNGHChart
496 | Component={Component}
497 | useRNGH
at detectHostComponentNames (node_modules/@testing-library/react-native/src/helpers/host-component-names.tsx:54:11)
at detectHostComponentNames (node_modules/@testing-library/react-native/src/helpers/host-component-names.tsx:27:30)
at renderInternal (node_modules/@testing-library/react-native/src/render.tsx:46:40)
at renderInternal (node_modules/@testing-library/react-native/src/render.tsx:29:10)
at Object.<anonymous> (src/__tests__/chart.test.tsx:494:13)
at asyncGeneratorStep (node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
at _next (node_modules/@babel/runtime/helpers/asyncToGenerator.js:22:9)
at node_modules/@babel/runtime/helpers/asyncToGenerator.js:27:7
at Object.<anonymous> (node_modules/@babel/runtime/helpers/asyncToGenerator.js:19:12)
Can the latest version work with RN 0.74? I encountered the above problem.
Closing as the root issues is resolved upstream.
@zhiqingchen check this comment for solution to your issue.
Closing as the root issues is resolved upstream.
@zhiqingchen check this comment for solution to your issue.
I change @react-native/babel-preset to 0.74.81. it works, thanks.
I am still having this issue, even inside components not using the Modal
.
Dependency Versions:
"react-native": "0.74.1",
"@react-native/babel-preset": "0.74.83",
"@react-native/eslint-config": "0.74.83",
"@react-native/metro-config": "0.74.83",
"@react-native/typescript-config": "0.74.83",
"@testing-library/react-native": "12.5.0",
"babel-plugin-module-resolver": "^5.0.2",
"react-test-renderer": "18.3.1",
"react": "18.3.1",
Babel.config.js:
module.exports = {
presets: ['module:@react-native/babel-preset'],
Test Failure Message:
FAIL __tests__/components/molecules/dir/dir/StepByStepSubmitReview.test.tsx
● StepByStepSubmitReview › renders correctly
Trying to detect host component names triggered the following error:
/Users/dir/code/app/node_modules/react-native/src/private/specs/components/AndroidSwitchNativeComponent.js: Cannot read properties of null (reading 'declarations')
There seems to be an issue with your configuration that prevents React Native Testing Library from working correctly.
Please check if you are using compatible versions of React Native and React Native Testing Library.
56 | const mockOnSubmit = jest.fn();
57 |
> 58 | const { toJSON, getByAccessibilityHint } = render(
| ^
59 | <StepByStepSubmitReview onSubmit={mockOnSubmit} />
60 | );
61 |
at detectHostComponentNames (node_modules/@testing-library/react-native/src/helpers/host-component-names.tsx:54:11)
at detectHostComponentNames (node_modules/@testing-library/react-native/src/helpers/host-component-names.tsx:27:30)
at renderInternal (node_modules/@testing-library/react-native/src/render.tsx:46:40)
at renderInternal (node_modules/@testing-library/react-native/src/render.tsx:29:10)
at Object.<anonymous> (__tests__/components/molecules/StepByStepTakeover/StepByStepSubmitReview/StepByStepSubmitReview.test.tsx:58:54)
Any help would be greatly appreciated!!
Describe the bug
Hey all!
I tried to run jest with react-native-testing-library, but it fails on RN 0.74.
Expected behavior
I expect it to run tests.
Steps to Reproduce
Add this code:
Screenshots
Versions