react/scripts/jest/patchMessageChannel.js
Sebastian Markbåge 1c43d0aed7
Unify serverAct helpers (#33327)
This uses the richer `serverAct` helper that we already use in other
tests.

This avoids using the `Scheduler`. We don't use that package on the
server so it doesn't make sense to simulate going through it.
Additionally, we really should be getting rid of it on the client too to
favor `postTask` polyfills.
2025-05-21 16:13:54 -04:00

22 lines
359 B
JavaScript

'use strict';
export function patchMessageChannel() {
global.MessageChannel = class {
constructor() {
const port1 = {
onmesssage: () => {},
};
this.port1 = port1;
this.port2 = {
postMessage(msg) {
setTimeout(() => {
port1.onmessage(msg);
}, 0);
},
};
}
};
}