When attempting to initialize WebGLRenderer in one of my Jest test cases, I encounter the following error:
Error creating WebGL context.
9 |
10 | it('should set the main renderer', () => {
> 11 | const webglRenderer: WebGLRenderer = new WebGLRenderer({
| ^
12 | antialias: true,
13 | alpha: true,
14 | powerPreference: 'high-performance',
at new WebGLRenderer (../../node_modules/three/build/three.js:19318:13)
at Object.<anonymous> (src/tests/managers/three-manager/renderer-manager.test.ts:11:42)
Although I'm testing TypeScript and not encountering any compile-time errors.
Full stack trace:
Error: Not implemented: HTMLCanvasElement.prototype.getContext (without installing the canvas npm package)
at module.exports (C:\..\Desktop\phoenix\node_modules\jsdom\lib\jsdom\browser\not-implemented.js:9:17)
at HTMLCanvasElementImpl.getContext (C:\..Desktop\phoenix\node_modules\jsdom\lib\jsdom\living\nodes\HTMLCanvasElement-impl.js:42:5)
at HTMLCanvasElement.getContext (C:\..\Desktop\phoenix\node_modules\jsdom\lib\jsdom\living\generated\HTMLCanvasElement.js:131:58)
at getContext (C:\..Desktop\phoenix\node_modules\three\build\three.js:19279:29)
at new WebGLRenderer (C:\..Desktop\phoenix\node_modules\three\build\three.js:19315:10)
at Object.<anonymous> (C:\..\Desktop\phoenix\packages\phoenix-event-display\src\tests\managers\three-manager\renderer-manager.test.ts:11:42)
at Promise.then.completed (C:\..Desktop\phoenix\node_modules\jest-circus\build\utils.js:391:28)
at new Promise (<anonymous>)
at callAsyncCircusFn (C:\..Desktop\phoenix\node_modules\jest-circus\build\utils.js:316:10)
at _callCircusTest (C:\..\Desktop\phoenix\node_modules\jest-circus\build\run.js:218:40) undefined
at VirtualConsole.<anonymous> (../../node_modules/jsdom/lib/jsdom/virtual-console.js:29:45)
at module.exports (../../node_modules/jsdom/lib/jsdom/browser/not-implemented.js:12:26)
at HTMLCanvasElementImpl.getContext (../../node_modules/jsdom/lib/jsdom/living/nodes/HTMLCanvasElement-impl.js:42:5)
at HTMLCanvasElement.getContext (../../node_modules/jsdom/lib/jsdom/living/generated/HTMLCanvasElement.js:131:58)
at getContext (../../node_modules/three/build/three.js:19279:29)
at new WebGLRenderer (../../node_modules/three/build/three.js:19315:10)
Chrome version: 102.0.5005.115 (Official Build) (64-bit) (cohort: Stable)
OS: Windows 11 Version 21H2 (Build 22000.739)
JavaScript: V8 10.2.154.8
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/102.0.0.0 Safari/537.36
chrome://gpu
WebGL: Hardware accelerated
WebGL2: Hardware accelerated
WebGPU: Hardware accelerated
Thank you in advance! :))