Skip to content

Testing Components Using @vis.gl/react-google-maps & @googlemaps/jest-mocks #204

Answered by usefulthink
apeTrackunit asked this question in Q&A
Discussion options

You must be logged in to vote

So here's a very rough sketch:

I'm assuming jest + @testing-library/react as testing framework (the idea applies to any other setup as well).
Suppose a component (much simpler than your example, but I hope that's enough to illustrate the point) like this:

import { AdvancedMarker } from '@vis.gl/react-google-maps';

type CustomMarkerProps = { label: string; position: google.maps.LatLngLiteral };

export const CustomMarker = (props: CustomMarkerProps) => {
  return (
    <AdvancedMarker position={props.position}>
      <h1>{props.label}</h1>
    </AdvancedMarker>
  );
};

So what do we need to test here? When testing the CustomMarker component, the only thing we need to verify is that the co…

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@usefulthink
Comment options

@apeTrackunit
Comment options

@usefulthink
Comment options

@usefulthink
Comment options

Answer selected by apeTrackunit
@usefulthink
Comment options

@alexander-lebed
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants