How to test leaflet based maps using testcafe?

我们两清 提交于 2020-04-15 03:55:35

问题


We are building a series of tests using TestCafe. How do we test if a point or path in a leaflet control is rendered correctly? To be more specific we are trying to test the lat-lon data of a circle marker in the map. But, we do not have any leaflet map/marker object available in the scope of testcafe scripts.

References:

Unit testing leaflet maps


回答1:


I created a simple example of an assertion for a path element in a leaflet control on the getting started demo page https://leafletjs.com/examples/quick-start/

import { Selector } from 'testcafe';

fixture `fixture`
    .page `https://leafletjs.com/examples/quick-start/`;

test('test', async t => {
    await t
        .switchToIframe('iframe')
        .expect(Selector('path').withAttribute('stroke', 'red').getAttribute('d')).eql('M141.20355555554852,171.94704600190744a42,42 0 1,0 84,0 a42,42 0 1,0 -84,0 ');
});

Please provide us with an example of your testing page so we will be able to offer you something more specific for your scenario.



来源:https://stackoverflow.com/questions/56432686/how-to-test-leaflet-based-maps-using-testcafe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!