Skip to content

Instantly share code, notes, and snippets.

@xphong
Last active June 23, 2020 09:08
Show Gist options
  • Save xphong/da749756386dae4adc23fa7c40cfbf19 to your computer and use it in GitHub Desktop.
Save xphong/da749756386dae4adc23fa7c40cfbf19 to your computer and use it in GitHub Desktop.
Cypress D3 Svg Drag and Drop
const dataTransfer = new DataTransfer()
cy.window().then((win) => {
cy.get('.dragButton')
.trigger('mousedown', { which: 1, view: win, force: true })
cy.get('.dragButton')
.trigger('dragstart', { dataTransfer, view: win, force: true })
.trigger('drag', { dataTransfer, view: win, force: true })
cy.get('.dropElement')
.trigger('mouseenter', { force: true, view: win })
.trigger('mouseup', { which: 1, button: 0, force: true, view: win })
cy.get('.draggedElements').should('have.length', 1)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment