jeudi 10 septembre 2020

spy on Bus doesn't work and calls occured

[1]I am beginning with cypress . I have a video application in which there is multiple call on EventBus class . The call from the typical application are done like this .

I would like to test if a click on a button effectively trigger the events

  const seekRelative = useCallback(
(timeToMove) => eventBus.emit(REQUEST.SEEK, currentTime + timeToMove),
[currentTime],);

a click on NEXT10S triggers the event,it's not a problem from this ( I logged it, and the button do his job to moove the timer of 10 seconds )

Here a part of the cypress code .

const eventBus = new EventBus();
const spyonBus=cy.spy(eventBus,'emit');
const spyOnEvent=spyonBus.withArgs(REQUEST.SEEK).as('requestSeek');
cy.get(`[CypressData="${DATACYPRESS.IMAGENAME.NEXT10}"]`).click();
expect(spyOnEvent).to.be.called;

[cypress screen] [1]: https://i.stack.imgur.com/gtBc4.png

Aucun commentaire:

Enregistrer un commentaire