-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjest.setup.ts
More file actions
38 lines (34 loc) · 854 Bytes
/
jest.setup.ts
File metadata and controls
38 lines (34 loc) · 854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import '@testing-library/jest-dom';
// Mock WebGPU globals
declare global {
interface Navigator {
gpu: any;
}
}
global.navigator.gpu = {
requestAdapter: async () => ({
requestDevice: async () => ({
createTexture: () => ({
width: 256,
height: 256,
format: 'rgba8unorm',
destroy: () => {}
}),
destroy: () => {}
})
})
};
// Mock WebGL2 context
const mockWebGL2Context = {
getExtension: () => ({
loseContext: () => {}
})
} as unknown as WebGL2RenderingContext;
// Mock canvas getContext
const originalGetContext = HTMLCanvasElement.prototype.getContext;
HTMLCanvasElement.prototype.getContext = function(contextId: string, options?: any) {
if (contextId === 'webgl2') {
return mockWebGL2Context;
}
return originalGetContext.call(this, contextId as any, options);
};