Open LesniakM opened 1 year ago
Thank you for sharing your tutorial at https://yonatankra.com/how-to-test-html5-canvas-with-jest/ .
I tried to replicate everything, even copied all your files, but still I had error "ReferenceError: Path2D is not defined".
The reason for that is fact, that nowadays Jest by default uses node environment, not JSdom anymore.
To solve this problem, file package.json should be changed from:
"jest": { "setupFiles": ["jest-canvas-mock"] }
to:
"jest": { "testEnvironment": "jsdom", "setupFiles": ["jest-canvas-mock"] }
Moreover, installing jest-environment-jsdom might be needed. It can be done with: npm i jest-environment-jsdom --save-dev
npm i jest-environment-jsdom --save-dev
As of December 2023, I can verify that the current commit still fails for the reasons stated by LesniakM.
His suggestions do fix the problem however.
Thank you to both Yonatan and Lesniak!!!
Thank you for sharing your tutorial at https://yonatankra.com/how-to-test-html5-canvas-with-jest/ .
I tried to replicate everything, even copied all your files, but still I had error "ReferenceError: Path2D is not defined".
The reason for that is fact, that nowadays Jest by default uses node environment, not JSdom anymore.
To solve this problem, file package.json should be changed from:
to:
Moreover, installing jest-environment-jsdom might be needed. It can be done with:
npm i jest-environment-jsdom --save-dev