-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.setup.js
More file actions
27 lines (22 loc) · 798 Bytes
/
Copy pathvitest.setup.js
File metadata and controls
27 lines (22 loc) · 798 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
// 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';
// global needs to be set before import jest-canvas-mock
global.jest = vi;
import 'jsdom-worker';
beforeAll(() => {
// jsdom doesn't come with a WebCrypto implementation (required for uuid)
global.crypto = {
getRandomValues: function (buffer) {
return randomFillSync(buffer);
}
};
// jsdom doesn't come with a `URL.createObjectURL` implementation
global.URL.createObjectURL = () => { return ''; };
});
afterAll(() => {
delete global.jest;
delete global.window.jest;
});