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
putImageData not updating the underlying data set #60
Comments
Right. These functions are very difficult to account for. We would need to use some kind of cpu bound to keep track of image data. At the moment, this is a "misuse" of jest-canvas-mock. Did I mention we accept pull requests? 😅 In all seriousness, this is a great feature to have, but very difficult to implement. At that point it might be better to use cairo or |
Hey @jtenner thanks for the response I wondered if it might be a misuse. I'll try and find some time to have a look. |
See now that I think about it, it looks like |
I have run into this same using |
Yes. You need to manually mock that function. Do you know how to the jest mock api to force different return values? |
I do, however, I thought the point of this library was to act as a poly-fill for |
I believe this library was initially created to do almost zero validation of user input. When I refactored and created the second version, emulating the save stack, I did not intend to perform actual draw calls to buffers. This felt like it was out of the scope of my expertise. This particular library covers the 99% use case for most users attempting to run their tests when they cannot decouple their tests from a canvas implementation. Your use case requires pixel verification, and it's likely you just need to use node-canvas and bootstrap the tests yourself, or mock the function returns manually. |
I've been experimenting with getImageData and putImageData, it's relatively new to me so apologies if I've missed a trick with this one. There are a few quirks some of which are outlined here notably that the data property is read only.
In the below test case when you attempt to get the imageData after it has been updated, the returned value is in fact the old data set. The same test when run in Chrome returns the newer data set. Is this a bug or misuse?
The text was updated successfully, but these errors were encountered: