Skip to content

Commit

Permalink
Add polyfill for MessageChannel in getDataFromTree test
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller committed Dec 13, 2024
1 parent 59e4bc8 commit 926a001
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
5 changes: 1 addition & 4 deletions config/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ const defaults = {
const ignoreTSFiles = ".ts$";
const ignoreTSXFiles = ".tsx$";

const react19TestFileIgnoreList = [
ignoreTSFiles,
"src/react/ssr/__tests__/getDataFromTree.test.tsx",
];
const react19TestFileIgnoreList = [ignoreTSFiles];

const react17TestFileIgnoreList = [
ignoreTSFiles,
Expand Down
15 changes: 15 additions & 0 deletions src/react/ssr/__tests__/getDataFromTree.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
import React from "react";

if (React.version.startsWith("19")) {
// react-dom/server uses MessageChannel in React 19
window.MessageChannel = jest.fn().mockImplementation(() => {
return {
port1: {
set onmessage(_cb: unknown) {},
},
port2: {
postMessage(_data: unknown) {},
},
};
});
}

import gql from "graphql-tag";
import { DocumentNode } from "graphql";

Expand Down

0 comments on commit 926a001

Please sign in to comment.