How to implement drag and drop in cypress test?

后端 未结 6 1388
青春惊慌失措
青春惊慌失措 2020-12-14 07:47

I am struggling to test drag and drop with Cypress and Angular Material Drag and Drop. So the goal is to move \"Get to work\" from Todo to Done. I have created the following

6条回答
  •  情歌与酒
    2020-12-14 08:15

    After a lot of battling, I managed to make the drag and drop work with this:

    cy.get('.list .item')
          .contains(startpos)
          .trigger('dragstart', { dataTransfer: new DataTransfer });
    cy.get('.list .item')
          .eq(endpos)
          .trigger('drop')
          .trigger('dragend');
    

    Pretty easy to use.

提交回复
热议问题