I'm looking to implement the Jest testing framework with React Pixi and am unable to get past this TypeError:
FAIL src/Stage.test.js
● Test suite failed to run
TypeError: Image or Canvas expected
at canUseNewCanvasBlendModes (./pixi-jest-test/node_modules/@pixi/canvas-renderer/src/utils/canUseNewCanvasBlendModes.ts:47:13)
Before this, I tried using forceCanvas and the canvas NPM library, but I couldn't get past a WebGL error despite using that forceCanvas option (not sure if opening a separate issue for that would be beneficial; if so let me know and I'll do that as well). This is why I end up mocking the WebGL canvas later.
Realizing as I'm going through again that I believe this is an issue with Pixi and not your repo, so I'll go ahead and close this. Sorry for the trouble!
Description
I'm looking to implement the Jest testing framework with React Pixi and am unable to get past this TypeError:
Before this, I tried using
forceCanvas
and thecanvas
NPM library, but I couldn't get past a WebGL error despite using thatforceCanvas
option (not sure if opening a separate issue for that would be beneficial; if so let me know and I'll do that as well). This is why I end up mocking the WebGL canvas later.I'm not an expert in canvas nor GL, so where it is showing an error in the Pixi code doesn't lead me to any good answers. The couple relevant Stack Overflow questions regarding this mention needing something to be async, but ¯\_(ツ)_/¯.
Steps to reproduce
npx create-react-app pixi-jest-test
react@17.0.0
react-dom@17.0.0
@inlet/react-pixi
canvas
gl
@testing-library/react
pixi.js-legacy
./src/setupTests.js
file to match as below.Stage.test.js
in thesrc
folder using the contents below.npm test
. You should get the above error.setupTests.js
Stage.test.js
Additional info
@inlet/react-pixi
version: 6.7.0React
version: 17.0.0ReactDOM
version: 17.0.0PIXI
version: 6.3.0 (legacy
is the same version)Thank you so much for your help, your repo is wonderful <3