Skip to content

Commit

Permalink
external deps example
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeyraspopov committed Apr 1, 2024
1 parent 3313090 commit e060110
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions examples/react/external.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { test } from "rollwright";
import { expect } from "@playwright/test";
import alias from "@rollup/plugin-alias";

test.use({
plugins: [
alias({
entries: [
{
find: /(react|react-dom)(\/.+|$)/,
replacement: "https://esm.sh/[email protected]$2",
customResolver: (id) => ({ id, external: true }),
},
],
}),
],
});

test("external", async ({ execute, page }) => {
let root = await execute(async () => {
let { createRoot } = await import("react-dom/client");
let section = document.createElement("section");
document.body.append(section);
let root = createRoot(section);
return root;
});

await execute(async (root) => {
let { jsx } = await import("react/jsx-runtime");
root.render(jsx("h1", { children: "Hello" }));
}, root);

await expect(page.locator("h1")).toContainText("Hello");
});

0 comments on commit e060110

Please sign in to comment.