-
Notifications
You must be signed in to change notification settings - Fork 1
/
jest.setup.ts
46 lines (42 loc) · 1.2 KB
/
jest.setup.ts
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
// @ts-nocheck
import { TextEncoder, TextDecoder } from "util";
import { randomFillSync } from "crypto";
import type { Config } from "jest";
// polyfill for jest crypto function (because of Injective ts sdk)
window.crypto = {
getRandomValues(buffer) {
return randomFillSync(buffer);
},
};
// polyfill for jest formatToJson function
Intl.DateTimeFormat.prototype.formatToJson = function (date: Date) {
const _this = this as Intl.DateTimeFormat;
return Object.fromEntries(
_this
.formatToParts(date)
.filter((item) => item.type !== "literal")
.map((item) => [item.type, item.value]),
) as Record<Intl.DateTimeFormatPartTypes, string>;
};
global.TextEncoder = TextEncoder;
global.TextDecoder = TextDecoder;
// const config: Config = {
// preset: "ts-jest/presets/js-with-ts",
// testEnvironment: "node",
// globals: {
// "ts-jest": {
// tsconfig: "<rootDir>/test/tsconfig.json",
// },
// },
// transform: {
// "^.+\\.ts?$": ["ts-jest", { isolatedModules: true }],
// },
// projects: [
// {
// displayName: "migrate-staking",
// testMatch: "<rootDir>/src/tests/migrate-staking.test.ts",
// },
// ],
// };
//
// export default config;