Search code examples
reactjsdrag-and-dropcypress

Cypress drag and drop a 'react sortable tree' element


I'm trying to use Cypress to drag and drop an element from the "react sortable tree" library https://github.com/frontend-collective/react-sortable-tree#troubleshooting

However, the usual way of doing this is not working. Things I've tried:

    cy.get(subject).trigger("mousedown", { which: 1, force: true })
                .trigger("mousemove", { pageX: xPos, pageY: yPos, force: true })
                .trigger("mouseup", { force: true })

OR

    cy.get(subject).trigger("mousedown", { button: 0, force: true })
    cy.get(target).trigger("mousemove")
              .trigger("mouseup")

Has anybody successfully tested drag and drop using Cypress on react sortable tree?


Solution

  •     cy.get(subject).trigger("dragstart")
        cy.get(target).trigger("drop")
                  .trigger("dragend")
    

    the above worked for me