-
Notifications
You must be signed in to change notification settings - Fork 290
/
jestSetup.js
30 lines (25 loc) · 922 Bytes
/
jestSetup.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
/* globals jest */
/* eslint-disable import/no-extraneous-dependencies */
import 'core-js/stable'
import 'regenerator-runtime/runtime'
import crypto from 'crypto'
import { TextEncoder, TextDecoder } from 'util'
// Force warnings to fail Jest tests.
// https://github.com/facebook/jest/issues/6121#issuecomment-444269677
const { error } = console
// eslint-disable-next-line func-names, no-console
console.error = function (message, ...args) {
error.apply(console, args) // keep default behaviour
throw message instanceof Error ? message : new Error(message)
}
// Next.js polyfills fetch
global.fetch = jest.fn()
// https://github.com/jsdom/jsdom/issues/1612
Object.defineProperty(global.self, 'crypto', {
value: {
subtle: crypto.webcrypto.subtle,
},
})
// https://github.com/inrupt/solid-client-authn-js/issues/1676#issuecomment-917016646
global.TextEncoder = TextEncoder
global.TextDecoder = TextDecoder