import { IllusionCore } from '../../core/illusion-core'; class WorkerMock { public onmessage?: (data: any) => void; private illusionCore: IllusionCore; constructor() { this.illusionCore = new IllusionCore(); } postMessage = jest.fn(async ({ id, type, data }: { id: number, type: string, data: any }, transfers: any) => { try { const result = await this.illusionCore.do(type, data); this.onmessage!({ data: { id, type, data: result } }); } catch(error) { this.onmessage!({ data: { id, type, error: error.message } }); } }) terminate = jest.fn(); } export default jest.fn().mockImplementation(() => new WorkerMock());