enzyme
enzyme copied to clipboard
How to test InteracationManager.runAfterInteractions().then(()=>this.myMethod(this.props)}) using jest
public componentDidMount() {
const { animateOnDidMount } = this.props;
if (animateOnDidMount) {
InteractionManager.runAfterInteractions().then(() => {
this.myMethod(this.props);
});
}
}
Iam using jest. I have created a component like this let sideComp=shallow(<MyComponent/>. It is react-native project. I need to invoke myMethod for improving codecoverage. how can I test this code and what assert I need to keep.
I have no idea what "IteractionManager" is, or what "runAfterInteractions" does. Can you elaborate?
did you figure it out?
Did you find any way to handle this when running with Jest?
I got mine playing nicely like this:
const useIsPageTransitioning = () => {
const [isTransitioning, setIsTransitioning] = React.useState(true);
React.useEffect(() => {
const interaction = InteractionManager.runAfterInteractions(() => {
setIsTransitioning(false);
});
return () => interaction.cancel()
}, []);
return isTransitioning;
};