-
Notifications
You must be signed in to change notification settings - Fork 279
How to fixed this <Provider> Error when testing my component to render #1582
-
PaperProvider is already present in the code -
Screenshot 2024年04月01日 at 11 10 06 AMBeta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment 1 reply
-
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
Beta Was this translation helpful? Give feedback.
All reactions
-
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 -
Beta Was this translation helpful? Give feedback.