-
Notifications
You must be signed in to change notification settings - Fork 342
/
setupJest.js
38 lines (29 loc) · 995 Bytes
/
setupJest.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
require('core-js')
const util = require('util')
global.TextEncoder = util.TextEncoder
global.TextDecoder = util.TextDecoder
global.browser = global.browser ?? {}
global.browser.runtime = global.browser.runtime ?? {}
global.browser.runtime.id = global.browser.runtime ?? 'test-id'
global.chrome = global.chrome ?? {}
global.chrome.runtime = global.chrome.runtime ?? {}
global.chrome.runtime.id = global.chrome.runtime ?? 'test-id'
global.fetch = require('jest-fetch-mock')
global.URL = require('url').URL
global.DataTransfer = function () {
this.data = ''
this.img = undefined
this.setData = (format, dataString) => (this.data = dataString)
this.getData = (format) => this.data
this.setDragImage = (img) => (this.img = img)
}
global.Blob = class Blob {}
global.document = global.document ?? {}
global.document.execCommand = () => true
global.navigator = {
userAgent: 'jest',
}
global.ResizeObserver = class ResizeObserver {
observe() {}
disconnect() {}
}