-
Notifications
You must be signed in to change notification settings - Fork 273
Trying to detect host component names triggered the following error #1413
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
Comments
Hello @Sahand-Stefan! If you get this error message then it means that there has to be some problem with your test setup that prevents the library from working correctly. Based on the information you gave I can't see what the problem really is, could you provide a minimal repro? Or at least provide your jest config and jest setup files? |
@Sahand-Stefan Pierre made good points about the setup issue, and the need to provide repro repository so that we can diagnose such issue. I would add following two thoughts: |
Thanks guys |
@najumasad can you please provide a repro or give the code for your |
Perhaps it would be useful to use |
I'm not sure it would make a difference. If we use host component names that do not match the mocks then test will fail no? And the error will be more difficult to debug because queries will fail whereas here we know that there is an issue with the test setup. Moreover I think we should recommend not mocking |
@pierrezimmermannbam With #1425 PR things get slightly improved as users should be able to mock whole |
Added Troubleshooting Guide entry about following error:
|
Ask your Question
beforeEach(() => {
// Render the component with default props for each test
component = render(<LActButton {...defaultProps} />)
})
I am using the testing library version : ^12.1.2
and the react native : o.71.8
And i get the following message for rendering my component
Trying to detect host component names triggered the following error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports. 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.
The text was updated successfully, but these errors were encountered: