I have this basic component, but whenever I try testing it with React Testing Library the only thing present on the screen is the div
with the "loading" text. I think this is because isLoaded
might not have a value when the component is first loaded.
How do I tell React Testing Library to wait until isLoaded
is true
so it can find other elements on the page?
import {
GoogleMap,
useJsApiLoader,
Autocomplete,
Marker,
} from "@react-google-maps/api";
export const Map = () => {
const { isLoaded } = useJsApiLoader("apikey");
return isLoaded ? (
<form>
<Autocomplete />
<GoogleMap>
<Marker />
</GoogleMap>
</form>
) : (
<div>loading</div>
);
};
export default Map;