I have a map (canvas) based application and on this element voyage-ol-map, I want to run invoke/run the $0.centerOn([0,0], true) function/command.
It's how I do it in UI - dev tools:
I locate the element in the 'Devtools: Elements' tab and then in 'Devtools: Console' I run $0.centerOn([0,0], true) which will make the map center-aligned (forces the map to be center-aligned from default view).
In Cypress, I tried this in order to make a visual capture but need some help as it is not working.
cy.get('voyage-ol-map')
.invoke('centerOn([0,0], true)');
Tried below also:
cy.get('voyage-ol-map')
.invoke('0.centerOn([0,0], true)');
cy.get('voyage-ol-map')
.invoke('$0.centerOn([0,0], true)');
Error in TR:
UPDATE: Using this
cy.get('voyage-ol-map')
.invoke('centerOn', [0, 0], true);
gives the below error.
Timed out retrying after 4000ms: cy.invoke() errored because the property: centerOn does not exist on your subject.
cy.invoke() waited for the specified property centerOn to exist, but it never did.
If you do not expect the property centerOn to exist, then add an assertion such as:
cy.wrap({ foo: 'bar' }).its('quux').should('not.exist')Learn more
cypress/pages/mapLayer_page.js:200:8
199 | cy.get('voyage-ol-map')
> 200 | .invoke('centerOn', [0, 0], true);
