Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

104
Vistas
Jest with Leaflet Markercluster

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.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda