-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathjest.setup.js
executable file
·46 lines (39 loc) · 1.2 KB
/
jest.setup.js
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
// No console.log() / setTimeout
console.log = jest.fn(() => {
throw new Error("Do not use console.log() in production");
});
jest.setTimeout(1000);
// jest speedup when errors are part of the game
Error.stackTraceLimit = 0;
global.Promise = require("promise");
import chai from "chai";
// Make sure chai and jasmine ".not" play nice together
// https://medium.com/@RubenOostinga/combining-chai-and-jest-matchers-d12d1ffd0303
const originalNot = Object.getOwnPropertyDescriptor(
chai.Assertion.prototype,
"not"
).get;
Object.defineProperty(chai.Assertion.prototype, "not", {
get() {
Object.assign(this, this.assignedNot);
return originalNot.apply(this);
},
set(newNot) {
this.assignedNot = newNot;
return newNot;
}
});
// Combine both jest and chai matchers on expect
const originalExpect = global.expect;
global.expect = actual => {
const originalMatchers = originalExpect(actual);
const chaiMatchers = chai.expect(actual);
return Object.assign(chaiMatchers, originalMatchers);
};
// TODO: Support Web3
// import dotenv from "dotenv";
// dotenv.config();
// do this to make sure we don't get multiple hits from both webpacks when running SSR
setTimeout(() => {
// do nothing
}, 1);