Skip to content

Commit 19ae6be

Browse files
committed
test: fix test config
1 parent 2321339 commit 19ae6be

File tree

5 files changed

+3644
-3933
lines changed

5 files changed

+3644
-3933
lines changed

__tests__/setups/url.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
window.URL.createObjectURL = jest.fn()

__tests__/setups/worker.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Worker {
2+
constructor(stringUrl) {
3+
this.url = stringUrl
4+
// eslint-disable-next-line @typescript-eslint/no-empty-function
5+
this.onmessage = () => {}
6+
}
7+
8+
postMessage(msg) {
9+
this.onmessage(msg)
10+
}
11+
}
12+
13+
window.Worker = Worker

jest.config.js

Lines changed: 5 additions & 1 deletion
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/'],
59
collectCoverageFrom: ['./src/**/*.{ts,tsx}', '!./**/*.d.ts'],
610
testEnvironment: 'jsdom',

0 commit comments

Comments
 (0)