title: How to simulate click on a react-leaflet Marker in my unit tests?
body: <p>I have this sample react-leaflet map implementation that renders the map and a marker that can be clicked.</p>
  
  <pre><code>import React from 'react';
  import { Map, TileLayer, Marker } from 'react-leaflet';
  
  
  export default class ScoutPlayers extends React.Component {
    render() {
      const state = {
          lat: 51.505,
          lng: -0.09,
          zoom: 13,
      };
  
      const position = [state.lat, state.lng]
      return (
        &lt;Map center={position} zoom={state.zoom}&gt;
          &lt;TileLayer
            attribution='&amp;amp;copy &lt;a href="http://osm.org/copyright"&gt;OpenStreetMap&lt;/a&gt; contributors'
            url='https://{s}.tile.openstreetmap.se/hydda/full/{z}/{x}/{y}.png'
          /&gt;
            &lt;Marker position={position} value={{id: 5}} onClick={(event) =&gt; {console.log(event.target.options.value)}} /&gt;
        &lt;/Map&gt;
      )
    }
  }
  </code></pre>
  
  <p>And I got a simple unit test that should test the click calls a function.</p>
  
  <pre><code>import { mount } from 'enzyme';
  import { Marker } from 'react-leaflet';
  import ScoutPlayers from './ScoutPlayers';
  
  describe('when displaying scout players map', () =&gt; {
      let scoutPlayers;
      beforeAll(() =&gt; {
          scoutPlayers = mount(&lt;ScoutPlayers/&gt;);
        });
  
      it('should call the api when player marker clicked', () =&gt; {  
          const player = scoutPlayers.find(Marker);
          expect(player).toHaveLength(1);
          player.simulate('click');
      });
  })
  </code></pre>
  
  <p>On <code>simulate('click')</code> is get the following error</p>
  
  <p><code>TypeError: Cannot read property '__reactInternalInstance$iexoharntw' of null</code></p>
  
  <p>Any ideas on how I could fix this? I thought <code>mount</code> should properly create the <code>Marker</code> element so that it can be clickable.</p>
  
  <p>I had a similar problem using GoogleMaps and its Marker in that the element could not be clicked because it has some properties initialised as null. I guess my other question would be how to properly test this kind of component as it has some critical business logic?</p>