I've got a basic React Native app that has been barely modified and initialized using Expo:
expo init AwesomeProject
cd AwesomeProject
yarn start
The initialized app has this class:
import {
ColorSchemeName,
useColorScheme as _useColorScheme,
} from "react-native";
export default function useColorScheme(): NonNullable<ColorSchemeName> {
return _useColorScheme() as NonNullable<ColorSchemeName>;
}
I'm going through the codebase and trying to add unit tests. I've added a few rendering tests for React Native components, but here I'm trying to unit test the useColorScheme() function. Since this is a React hook, I can't call it outside of a React function body.
// Using jest
import useColorScheme from "../useColorScheme";
it('useColorScheme', () => {
const huh = useColorScheme();
});
So basically my question is - What's the best way to call a React hook using jest since the hooks can only be called from a React function? (Let it be noted that I am quite new to javascript, typescript, and React)