diff --git a/public/test/jest-setup.ts b/public/test/jest-setup.ts index 72a8d66c0dc..7eef807e199 100644 --- a/public/test/jest-setup.ts +++ b/public/test/jest-setup.ts @@ -42,6 +42,22 @@ window.matchMedia = (query) => ({ dispatchEvent: jest.fn(), }); +window.MessageChannel = jest.fn().mockImplementation(() => { + let onmessage: Function; + return { + port1: { + set onmessage(cb: Function) { + onmessage = cb; + }, + }, + port2: { + postMessage: (data: unknown) => { + onmessage?.({ data }); + }, + }, + }; +}); + angular.module('grafana', ['ngRoute']); angular.module('grafana.services', ['ngRoute', '$strap.directives']); angular.module('grafana.panels', []);