Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

102
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda