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.

Revisions

  1. fernyb created this gist Aug 28, 2021.
    23 changes: 23 additions & 0 deletions cypress-canvas-draw.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    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);
    // });
    });