I started getting this error while running tests today:
Error: Not implemented: HTMLCanvasElement.prototype.getContext (without installing the canvas npm package)
at module.exports (/workspace/rpg/v4/node_modules/jsdom/lib/jsdom/browser/not-implemented.js:9:17)
at HTMLCanvasElementImpl.getContext (/workspace/rpg/v4/node_modules/jsdom/lib/jsdom/living/nodes/HTMLCanvasElement-impl.js:42:5)
at HTMLCanvasElement.getContext (/workspace/rpg/v4/node_modules/jsdom/lib/jsdom/living/generated/HTMLCanvasElement.js:131:58)
at HTMLCanvasElement.getContext (file:///workspace/rpg/v4/node_modules/vitest-webgl-canvas-mock/src/mock/prototype.js:33:32)
at ContextSystem.createContext (file:///workspace/rpg/v4/node_modules/@pixi/core/src/context/ContextSystem.ts:272:25)
at ContextSystem.initFromOptions (file:///workspace/rpg/v4/node_modules/@pixi/core/src/context/ContextSystem.ts:253:25)
at ContextSystem.init (file:///workspace/rpg/v4/node_modules/@pixi/core/src/context/ContextSystem.ts:212:18)
at Runner.emit (file:///workspace/rpg/v4/node_modules/@pixi/runner/src/Runner.ts:82:22)
at StartupSystem.run (file:///workspace/rpg/v4/node_modules/@pixi/core/src/startup/StartupSystem.ts:60:31)
at new _Renderer (file:///workspace/rpg/v4/node_modules/@pixi/core/src/Renderer.ts:362:22) undefined
I googled the issue and I found that I should probably install vitest-canvas-mock
, but not everyone gets this issue though. Even on my GitHub pipeline, this issue does not occur.
Anyway, I wanted to extend vitest.config.ts
, but it seems impossible with the current implementation (?).
I tried using merge config
but when I want to import base config like this:
import defaultConfig from '@rpgjs/compiler/src/test/vitest.config';
I am getting this error:
Error: Build failed with 1 error:
node_modules/vite/node_modules/esbuild/lib/main.js:1373:27: ERROR: [plugin: externalize-deps] "@rpgjs/compiler/src/test/vitest.config" resolved to an ESM file. ESM file cannot be loaded by `require`. See http://vitejs.dev/guide/troubleshooting.html#this-package-is-esm-only for more details.
at failureErrorWithLog (/workspace/rpg/v4/node_modules/vite/node_modules/esbuild/lib/main.js:1649:15)
at /workspace/rpg/v4/node_modules/vite/node_modules/esbuild/lib/main.js:1058:25
at runOnEndCallbacks (/workspace/rpg/v4/node_modules/vite/node_modules/esbuild/lib/main.js:1484:45)
at buildResponseToResult (/workspace/rpg/v4/node_modules/vite/node_modules/esbuild/lib/main.js:1056:7)
at /workspace/rpg/v4/node_modules/vite/node_modules/esbuild/lib/main.js:1085:16
at responseCallbacks.<computed> (/workspace/rpg/v4/node_modules/vite/node_modules/esbuild/lib/main.js:703:9)
at handleIncomingPacket (/workspace/rpg/v4/node_modules/vite/node_modules/esbuild/lib/main.js:762:9)
at Socket.readFromStdout (/workspace/rpg/v4/node_modules/vite/node_modules/esbuild/lib/main.js:679:7)
at Socket.emit (node:events:519:28)
at addChunk (node:internal/streams/readable:559:12) {
errors: [
{
detail: Error: "@rpgjs/compiler/src/test/vitest.config" resolved to an ESM file. ESM file cannot be loaded by `require`. See http://vitejs.dev/guide/troubleshooting.html#this-package-is-esm-only for more details.
at file:///workspace/rpg/v4/node_modules/vite/dist/node/chunks/dep-df561101.js:66190:35
at requestCallbacks.on-resolve (/workspace/rpg/v4/node_modules/vite/node_modules/esbuild/lib/main.js:1373:28)
at handleRequest (/workspace/rpg/v4/node_modules/vite/node_modules/esbuild/lib/main.js:729:19)
at handleIncomingPacket (/workspace/rpg/v4/node_modules/vite/node_modules/esbuild/lib/main.js:755:7)
at Socket.readFromStdout (/workspace/rpg/v4/node_modules/vite/node_modules/esbuild/lib/main.js:679:7)
at Socket.emit (node:events:519:28)
at addChunk (node:internal/streams/readable:559:12)
at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
at Readable.push (node:internal/streams/readable:390:5)
at Pipe.onStreamRead (node:internal/stream_base_commons:190:23),
id: '',
location: [Object],
notes: [Array],
pluginName: 'externalize-deps',
text: '"@rpgjs/compiler/src/test/vitest.config" resolved to an ESM file. ESM file cannot be loaded by `require`. See http://vitejs.dev/guide/troubleshooting.html#this-package-is-esm-only for more details.'
}
],
warnings: []
}
Is it possible somehow to extend vitest config?