Skip to content
Closed
Prev Previous commit
Next Next commit
fix benchmark boilerplate code
  • Loading branch information
JonasBa committed Jul 18, 2024
commit bfe56c47af9c21d62a3b43034ba7cddc43fa21a0
20 changes: 7 additions & 13 deletions packages/rrweb/test/benchmark/dom-mutation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,6 @@ describe('benchmark: mutation observer', () => {
return fs.readFileSync(filePath, 'utf8');
};

const addRecordingScript = async (page: Page) => {
// const scriptUrl = `${getServerURL(server)}/rrweb-1.1.3.js`;
const scriptUrl = `${getServerURL(server)}/rrweb.umd.cjs`;
await page.evaluate((url) => {
const scriptEl = document.createElement('script');
scriptEl.src = url;
document.head.append(scriptEl);
}, scriptUrl);
await page.waitForFunction('window.rrweb');
};

for (const suite of suites) {
it(suite.title, async () => {
page = await browser.newPage();
Expand All @@ -110,12 +99,17 @@ describe('benchmark: mutation observer', () => {
const loadPage = async () => {
if ('html' in suite) {
await page.goto('about:blank');
const code = fs.readFileSync(path.resolve(__dirname, '../../dist/rrweb.umd.cjs')).toString()
await page.setContent(`<html>
<script>
${code.toString()}
</script>
</html>`);

await page.setContent(getHtml.call(this, suite.html));
} else {
await page.goto(suite.url);
}

await addRecordingScript(page);
};

const getDuration = async (): Promise<number> => {
Expand Down