'Select canvas shapes in Konva.js for testing
I have hundreds of shapes in canvas when onClick on a shape will take an action.
In my feature test, I am currently simulating the mouse click on a particular pixel. However, this is not ideal because the position of the graph may change. Unlike SVG, canvas doesn't expose the particular shape in the DOM. Is there a way to select the shape in a canvas by id for testing purposes?
Solution 1:[1]
You can use selectors to find any node inside the stage https://konvajs.org/docs/selectors/Select_by_id.html
const shape = stage.findOne('#id');
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | lavrton |
