forked from SolidOS/solid-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.ts
More file actions
33 lines (28 loc) · 1.05 KB
/
setup.ts
File metadata and controls
33 lines (28 loc) · 1.05 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
import { toContainGraph } from '../custom-matchers/toContainGraph'
import { toEqualGraph } from '../custom-matchers/toEqualGraph'
import { error, log, trace, warn } from '../../src/debug'
import 'isomorphic-fetch'
import { TextEncoder, TextDecoder } from 'util'
// https://stackoverflow.com/questions/52612122/how-to-use-jest-to-test-functions-using-crypto-or-window-mscrypto
// globalThis.crypto = require('crypto').webcrypto // with node >=16
const nodeCrypto = require('crypto')
global.crypto = {
getRandomValues: function (buffer) {
return nodeCrypto.randomFillSync(buffer)
}
}
global.TextEncoder = TextEncoder
global.TextDecoder = TextDecoder
// We don't want to output debug messages to console as part of the tests
jest.mock('../../src/debug')
export function silenceDebugMessages () {
;(log as any).mockImplementation(() => null)
;(warn as any).mockImplementation(() => null)
;(error as any).mockImplementation(() => null)
;(trace as any).mockImplementation(() => null)
}
// adding custom matchers
expect.extend({
toContainGraph,
toEqualGraph
})