Open masakudamatsu opened 3 years ago
Try jest-canvas-mock
. The following code snippet seems to work:
const events = ctx.__getEvents();
expect(events).toMatchSnapshot();
We cannot use jest-canvas-mock
. It's meant for unit tests of all the canvas functions. We need to access to the context
object in a test. I don't know how.
As suggested in this article, Cypress image snapshot test seems to be a way to go.
How to use cypress-image-snapshot is summarized in: https://www.notion.so/Visual-Testing-Cypress-Image-Snapshot-2cb49e721b0e4959b5ec2cb6adbd30ae
Read this and finalize how we test canvas elements with it.
This issue will need to be dropped if we decide not to use HTML5 Canvas to render the color triangle (#4 ).
See https://www.notion.so/Assertion-Canvas-element-d79e9249d87d4d8f9c6af63a8dc73528