Skip to content

Commit c075ad9

Browse files
committed
test(napi): cover React Compiler warning bailouts
1 parent 186ae8f commit c075ad9

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

napi/transform-react/test/transform.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,30 @@ describe("transformSync", () => {
145145
expect(result.code).toContain("[CSS_VAR]");
146146
expect(result.code).toContain("import { CSS_VAR }");
147147
});
148+
149+
it("continues after an incompatible library bailout", () => {
150+
const result = transformSync(
151+
"Components.tsx",
152+
`import { useReactTable } from "@tanstack/react-table";
153+
function Table() {
154+
const table = useReactTable({});
155+
return <div>{table}</div>;
156+
}
157+
export function Component(props: { text: string }) {
158+
return <span>{props.text}</span>;
159+
}`,
160+
);
161+
162+
expect(result.errors).toHaveLength(1);
163+
expect(result.errors[0]).toMatchObject({
164+
severity: "Warning",
165+
message: "[ReactCompiler] IncompatibleLibrary: Use of incompatible library",
166+
});
167+
expect(result.errors.some((error) => error.message.includes("Unexpected error"))).toBe(false);
168+
expect(result.code).toContain("react/compiler-runtime");
169+
expect(result.code).not.toContain("props: { text: string }");
170+
expect(result.code).not.toContain("<span");
171+
});
148172
});
149173

150174
describe("transform", () => {

0 commit comments

Comments
 (0)