-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathscript.mjs
38 lines (29 loc) · 1.06 KB
/
script.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const startTime = Date.now();
import { chromium } from "playwright";
import { startAppServer } from "../demo-app/server.js";
import newTrackerClient from "react-render-tracker/headless-browser-client";
async function runReactScenarioSet(run) {
const [browser, server] = await Promise.all([
chromium.launch({ headless: true }),
startAppServer(),
]);
await run(async function runReactScenario(url, scenario) {
const page = await browser.newPage();
const rrt = await newTrackerClient(page);
await page.goto(new URL(url, server.host).href);
await scenario({ browser, page, rrt });
await page.close();
});
await browser.close();
await server.close();
}
runReactScenarioSet(async runReactScenario => {
await runReactScenario("/", async ({ page, rrt }) => {
const eventCountBeforeAction = await rrt.getEventCount();
// do some actions
await page.click("button");
// dump events after an action
console.log(await rrt.getEvents(eventCountBeforeAction));
});
console.log("DONE in", Date.now() - startTime, "ms");
});