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

420
Visualizações
Test dragging a Mapbox GL map in Cypress

This question is similar to the following:

  1. Test dragging a Leaflet map in Cypress
  2. Cypress & Google Maps dragging moves elements, not the map

I want to be able to simulate a user clicking and dragging to pan a Mapbox GL JS map a certain distance. While it seems like the proper way, using the cypress trigger function doesn't appear to work. For the Leaflet link, a separate plugin that manipulates html canvas was used. Is there a similar workaround for panning using Mapbox?

I have created a standalone repo here that has one other test for marker actions as well: https://github.com/brianbancroft/example-mapbox-cypress-e2e

Here's the test itself:

  it("drags ", () => {
    const map = cy.get("#map");
    map.should("exist");

    const canvas = cy.get(".mapboxgl-canvas");

    map
      .trigger("mouseenter", 700, 250)
      .trigger("mousedown", 700, 250, {
        bubbles: true,
        waitForAnimations: true,
        // which: 1,
        // pageX: 700,
        // pageY: 250,
      })
      // .wait(100)
      .trigger("mousemove", {
        bubbles: true,
        waitForAnimations: true,
        pageX: 550,
        pageY: 250,
        which: 1,
      })
      .wait(100)
      .trigger("mouseup", {
        bubbles: true,
        waitForAnimations: true,
        which: 1,
        pageX: 550,
        pageY: 250,
      })
      .wait(100);

});
   

What I want to see: The map panning in the cypress browser environment What I see: The map not panning

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