Skip to content

Commit f76ce4a

Browse files
committed
test: add jest setups
1 parent c9009b7 commit f76ce4a

File tree

4 files changed

+5442
-5453
lines changed

4 files changed

+5442
-5453
lines changed

__tests__/setups/url.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
window.URL.createObjectURL = jest.fn()

__tests__/setups/worker.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Worker {
2+
constructor(stringUrl) {
3+
this.url = stringUrl
4+
this.onmessage = jest.fn()
5+
}
6+
7+
postMessage(msg) {
8+
this.onmessage(msg)
9+
}
10+
}
11+
12+
window.Worker = Worker

jest.config.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
module.exports = {
22
preset: '@opd/jest-preset-pangu',
3-
setupFiles: ['jest-canvas-mock'],
3+
setupFiles: [
4+
'jest-canvas-mock',
5+
'./__tests__/setups/worker.js',
6+
'./__tests__/setups/url.js',
7+
],
48
transformIgnorePatterns: ['/node_modules/', '/src/.umi/'],
59
collectCoverageFrom: [
610
'./src/**/*.{ts,tsx}',

0 commit comments

Comments
 (0)