Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I test fabric.js with cypress? #2378

Closed

Comments

@nitingupta220
Copy link

I'm using fabric.js in my website.
I want to test it using cypress.
Can you tell me how to do it?
@jennifer-shehane @brian-mann

@Francismb
Copy link

This is my best guess.

  • Get an instance of the canvas
  • Perform your mutations to the canvas the same way you would in normal javascript
  • Serialize the canvas and compare it to a snapshot.

@nitingupta220
Copy link
Author

@frazboyz I got the instance but then the actions that I want to do on it is not possible.
Because no command is working on the canvas.

@Francismb
Copy link

Francismb commented Aug 21, 2018

Try something like this.

cy.get('canvas').then(canvas => {
    const element = canvas.get(0);
   // Mutate the canvas using standard javascript, if you need to use another library, you will need to add that to your cypress project.
   return canvas;
});

@Francismb
Copy link

I would also suggest reading the Cypress documentation further.

@sainthkh
Copy link
Contributor

If you have any other questions, please use https://github.com/cypress-io/cypress/discussions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment