Skip to content

Instantly share code, notes, and snippets.

@fernyb
Created August 28, 2021 17:32
Show Gist options
  • Save fernyb/2bc1feda9b02f186fb89f16e708a500a to your computer and use it in GitHub Desktop.
Save fernyb/2bc1feda9b02f186fb89f16e708a500a to your computer and use it in GitHub Desktop.
Cypress draw on canvas
it("Draw on canvas", () => {
const drawLine = (x, y) => {
// cy.get("#canvas")
// .trigger("mousedown", x, y)
// .trigger("mousemove", x, y)
// .trigger("mousemove", x += 100, y)
// .trigger("mousemove", x += 100, y)
// .trigger("mousemove", x += 100, y)
// .trigger("mouseup", { force: true });
cy.get("#canvas")
.trigger("mousedown", x, y)
.trigger("mousemove", x, y)
.trigger("mousemove", { offsetX: x, offsetY: y })
.trigger("mousemove", { offsetX: x += 100, offsetY: y })
.trigger("mousemove", { offsetX: x += 100, offsetY: y })
.trigger("mouseup", { force: true });
};
// Cypress._.times(10, (idx) => {
drawLine(20, 50);
// });
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment