Here’s the code sample from our tutorial on how to simulate drag and drop actions in Cypress

 

describe("Drag and Drop", () => {
beforeEach(() => {
cy.visit('/ingredients/drag-and-drop');
});
it('should drag fried chicken to the order', () => {
const dataTransfer = new DataTransfer();
cy.get('#menu-fried-chicken').trigger('dragstart', {
dataTransfer
});
cy.get('#plate').trigger('drop', {
dataTransfer
});
});
it('should drag ice cream to the order', () => {
cy.get('#menu-ice-cream').drag('#plate-items');
});
});

View on GitHub
Colby Fayock
Developer Advocate

Ready for the next generation of testing?

Get started today Schedule a demo