konva/test/node-canvas-global-setup.mjs
Anton Lavrevov e33341d3f6 refactor
2025-08-11 20:34:32 +09:00

22 lines
554 B
JavaScript

export async function mochaGlobalSetup() {
// Load node-canvas polyfills on the compiled test output
// Path from this file (test/) to compiled file (.test-temp/src/...)
try {
await import(
new URL('../.test-temp/src/canvas-backend.js', import.meta.url)
);
} catch (e) {
// If not compiled yet or path missing, keep going; tests that need it will fail clearly
}
globalThis.Path2D ??= class Path2D {
constructor(path) {
this.path = path;
}
get [Symbol.toStringTag]() {
return `Path2D`;
}
};
}