Open sanchitos opened 1 year ago
I am having the same issue. I will probably have to mock it in order to get it to pass various tests.
Just ran into this as well, you can mock it with
jest.mock('rn-tooltip', () => {
return (props) => {
return <View>{props.children}</View>;
};
});
@visormatt unless you have created a div
component in react native your code snippet above would probably not work. This is what I had to implement in my projects global mocks to get this passing unit tests.
jest.mock('rn-tooltip', () => {
const React = require('react');
const { View } = require('react-native');
return ({ children }) => {
<View>{children}</View>;
};
});
Thanks, yeah for RN we should be mocking with a View
there 👍 . Jumping between platforms 🤷 but appreciate the callout 💯
@visormatt unless you have created a
div
component in react native your code snippet above would probably not work. This is what I had to implement in my projects global mocks to get this passing unit tests.jest.mock('rn-tooltip', () => { const React = require('react'); const { View } = require('react-native'); return ({ children }) => { <View>{children}</View>; }; });
This works for me, thx.
i've got a problem with the ref so i did this mock inside of my jest.setup, hope this helps:
jest.mock('rn-tooltip', () => {
const { View } = require('react-native');
const React = require('react');
return React.forwardRef((props, ref) => {
if (ref) {
ref.current = {
toggleTooltip: jest.fn(),
showTooltip: jest.fn(),
hideTooltip: jest.fn(),
};
}
const { children } = props;
return <View {...props}>{children}</View>;
});
});
I am using the library, it works perfectly. Now I need to do some tests over my component.
My settings:
I have this error:
I have tried a lot of things in order to make it work. Any suggestion?