Skip to content

Commit e060110

Browse files
external deps example
1 parent 3313090 commit e060110

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

examples/react/external.spec.tsx

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { test } from "rollwright";
2+
import { expect } from "@playwright/test";
3+
import alias from "@rollup/plugin-alias";
4+
5+
test.use({
6+
plugins: [
7+
alias({
8+
entries: [
9+
{
10+
find: /(react|react-dom)(\/.+|$)/,
11+
replacement: "https://esm.sh/[email protected]$2",
12+
customResolver: (id) => ({ id, external: true }),
13+
},
14+
],
15+
}),
16+
],
17+
});
18+
19+
test("external", async ({ execute, page }) => {
20+
let root = await execute(async () => {
21+
let { createRoot } = await import("react-dom/client");
22+
let section = document.createElement("section");
23+
document.body.append(section);
24+
let root = createRoot(section);
25+
return root;
26+
});
27+
28+
await execute(async (root) => {
29+
let { jsx } = await import("react/jsx-runtime");
30+
root.render(jsx("h1", { children: "Hello" }));
31+
}, root);
32+
33+
await expect(page.locator("h1")).toContainText("Hello");
34+
});

0 commit comments

Comments
 (0)