Closed wojtekmaj closed 1 year ago
@wojtekmaj I'm having same issue, do you know how to solve it ?
I'm also having this issue
I'm also having this issue
@treardon17
I ended up forking jest-canvas-mock in a my github and doing the following:
this is the content of vitest-canvas-mock.ts:
import { afterAll, vi } from 'vitest';
// @ts-expect-error: Global type missing
global.jest = vi;
// eslint-disable-next-line import/first
import getCanvasWindow from 'jest-canvas-mock/src/window'; // here is my fork with changes in the code
const apis = [
'Path2D',
'CanvasGradient',
'CanvasPattern',
'CanvasRenderingContext2D',
'DOMMatrix',
'ImageData',
'TextMetrics',
'ImageBitmap',
'createImageBitmap',
] as const;
const canvasWindow = getCanvasWindow({ document: window.document });
apis.forEach((api) => {
global[api] = canvasWindow[api];
global.window[api] = canvasWindow[api];
});
afterAll(() => {
delete global.jest;
delete global.window.jest;
});
@alcasas thanks for the tip!
I'm having this problem as well. The fix by @alcasas didn't work.
@nickyvanurk you can probs do this for now
import { afterAll, vi } from 'vitest';
global.jest = vi;
declare global {
var jest: typeof vi | undefined
}
Add that in a setup file.
Please reopen if the issue continues to exist.
@nickyvanurk you need to look into the error, then see where is failing, for sure is a method referenced to jest that doesn't exists, so you need to change it in your forked repository to not use that specific reference
This is the error I faced when testing
react-pdf
: