I need to test a leaflet map (which download tiles, css, etc) but I can't simulate tile download with Cypress.
When my Cypress test open the map, it tries to download urls like https://tile.openstreetmap.se/hydda/base/6/31/22.png, https://basemaps.cartocdn.com/light_nolabels/6/31/22.png or https://server.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/6/31/22.png If I do nothing, my test is locked on cy.visit because there is still some resources that wait to be downloaded I tried to intercept these urls but I end up with a leaflet error.
Uncaught Error: Uncaught (in promise): TypeError: Cannot read property 'replace' of undefined
TypeError: Cannot read property 'replace' of undefined
at LeafletTilesFallbackDirective.getSampleImgURLFromTileTemplate (leaflet-tiles-fallback.directive.ts:95)
When I use
cy.fixture('images/tile.png').then( image => {
cy.intercept("https://tile.openstreetmap.se/hydda/base/6/31/22.png", image)
cy.intercept("https://basemaps.cartocdn.com/light_nolabels/6/31/22.png", image)
cy.intercept("https://server.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/6/31/22.png", image)
})
My CI slave don't have acces to internet so I can't afford to wait for the "real" tiles to be downloaded so I need to mock the mecanism but don't know how to do it....
Thanks in advance