I have an issue testing something related to markerCluster. I'm using the leaflet.markercluster npm package, version 1.5.1. I'm doing something similar to an example on the git page, using the imports below:
import * as L from 'leaflet';
import 'leaflet.markercluster';
import "leaflet.markercluster/dist/leaflet.markercluster";
import "leaflet.markercluster/dist/MarkerCluster.css";
import "leaflet.markercluster/dist/MarkerCluster.Default.css";
the variable I'm writing:
const clusterItems = L.markerClusterGroup({
chunkedLoading: true,
showCoverageOnHover: false,
iconCreateFunction: customIcon,
removeOutsideVisibleBounds: true,
disableClusteringAtZoom:18
});
I'm also using react as my frontend library, with typescript if you needed to know.
Thing is, works fine when actually running the service. But when it comes to testing, using Jest and Enzyme, I always immediately get this error:
Test suite failed to run
TypeError: L.markerClusterGroup is not a function
And the results always point right back to the line of
const clusterItems = L.markerClusterGroup
I know others have had this same error, but normally that seems to happen when trying to run their project. In this case, I only get this error when trying to run tests. I've tried some ideas, like trying to use spyOn the clusterItems variable, mock an implementation, mock leaflet package, but no avail. And I can't find any specific case like this when looking around either.