JustFly1984 / react-google-maps-api

React Google Maps API
MIT License
1.76k stars 426 forks source link

How can i make test? #3167

Open misaku opened 1 year ago

misaku commented 1 year ago

i cant understand how can i make test with jest.

ranggabadrus commented 1 year ago

same question!

JustFly1984 commented 1 year ago

Not possible to unit Test.

murilogok commented 1 year ago

Do as follow:

jest.mock('@react-google-maps/api', () => {
  return {
    withGoogleMap: (Component: any) => Component,
    withScriptjs: (Component: any) => Component,
    Marker: (props: any) => <div {...props} />,
    GoogleMap: (props: any) => (
      <div>
        <div className="mock-google-maps" />
        {props.children}
      </div>
    ),
    InfoWindow: (props: any) => <div {...props} />,
    useLoadScript: () => ({
      isLoaded: true
    })
  }
})