Skip to content

Commit

Permalink
fix jest polyfills
Browse files Browse the repository at this point in the history
  • Loading branch information
vzaidman committed Dec 28, 2024
1 parent cd969a0 commit 1f524c0
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions jest.polyfills.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,21 @@ Object.defineProperties(globalThis, {
Blob: { value: Blob },
File: { value: File },
});

window.MessageChannel = jest.fn().mockImplementation(() => {
let onmessage;
return {
port1: {
set onmessage(cb) {
onmessage = cb;
},
},
port2: {
postMessage: data => {
if (onmessage) {
onmessage({ data });
}
},
},
};
});

0 comments on commit 1f524c0

Please sign in to comment.