Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How to fixed this <Provider> Error when testing my component to render #1582

Unanswered
SharveParihar asked this question in Q&A
Discussion options

You must be logged in to vote

Replies: 1 comment 1 reply

Comment options

Does FABGroup component contains the provider or upper level component provides it? If a upper component contains the provider ( like App.tsx ) and you test the below level component you should pass the provider when testing. You can accomplish this by wrapper property second parameter as options in render function

If it does not solve the problem let me know more detail about your implementation @SharveParihar

You must be logged in to vote
1 reply
Comment options

I am using react-native-paper and provider is added at the root level of app,

`
import { PaperProvider } from 'react-native-paper';

< PaperProvider > theme={DefaultTheme}
// ... Other Code for FAB Group
< /PaperProvider >

`

So I have also tried to add paper provider in my test file but it is failing with another error , that is given below -

`test('if it renders correctly', () => {
render( <FABGroup {...FABGroup.args} /> );

// Check FAB Group is rendered
const buttonElement = screen.getByTestId(FABGroup.args.testID);
expect(buttonElement).not.toBeNull();

});
`
Given below is the error -

Screenshot 2024年04月01日 at 10 04 36 PM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /