forked from vitessce/vitessce
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.setup.js
More file actions
50 lines (41 loc) · 1.6 KB
/
vitest.setup.js
File metadata and controls
50 lines (41 loc) · 1.6 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
// References:
// - https://github.com/gosling-lang/gosling.js/blob/master/scripts/setup-vitest.js
// - https://github.com/vitest-dev/vitest/issues/1377#issuecomment-1141411249
import { afterAll, vi, beforeAll } from 'vitest';
//import { randomFillSync } from 'crypto';
import intersection from 'set.prototype.intersection';
import 'vitest-canvas-mock';
import 'jsdom-worker';
import '@testing-library/jest-dom/vitest';
beforeAll(() => {
// jsdom doesn't come with a WebCrypto implementation (required for uuid)
// Update: no longer needed since upgrading to Node 20+?
/*
global.crypto = {
getRandomValues: function (buffer) {
return randomFillSync(buffer);
}
};
*/
// jsdom doesn't come with a `URL.createObjectURL` implementation
global.URL.createObjectURL = () => { return ''; };
// Set.prototype.intersection is only available as of NodeJS 22 and later.
intersection.shim();
/*
class WebGLRenderingContextShim {}
Object.assign(WebGLRenderingContextShim, {
VERTEX_SHADER: 0x8B31,
FRAGMENT_SHADER: 0x8B30,
});
class WebGL2RenderingContextShim extends WebGLRenderingContextShim {}
global.WebGLRenderingContext ??= WebGLRenderingContextShim;
global.WebGL2RenderingContext ??= WebGL2RenderingContextShim;
global.HTMLCanvasElement ??= class {};
global.OffscreenCanvas ??= class {};
global.createImageBitmap ??= async () => ({});
// Mock neuroglancer so import side-effects don’t run in Node
vi.mock('@janelia-flyem/neuroglancer', () => ({
setupDefaultViewer: () => ({}),
}));
*/
});