Skip to content

Commit

Permalink
fixing session recorder test
Browse files Browse the repository at this point in the history
  • Loading branch information
BatMiles committed Aug 28, 2024
1 parent 34742e1 commit d2ade34
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
14 changes: 8 additions & 6 deletions __tests__/session-recording.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import { launch, devices } from "puppeteer";
import { launch, KnownDevices } from "puppeteer";
import { defaultPuppeteerBrowserOptions } from "../src/pptr-utils/default";
import { setupSessionRecordingInspector } from "../src/session-recording";
import { autoScroll } from "../src/pptr-utils/interaction-utils";
// jest.setTimeout(30000);
it.skip("checks network requests for known session recorders", async () => {
import { BlacklightEvent } from "../src/types";

jest.setTimeout(30000); // This is a long-running test
it("checks network requests for known session recorders", async () => {
const browser = await launch({
...defaultPuppeteerBrowserOptions,
headless: true,
});

const page = (await browser.pages())[0];
await page.emulate(devices["iPhone 13 Mini"]);
const rows = [];
await page.emulate(KnownDevices["iPhone 13 Mini"]);
const rows: BlacklightEvent[] = [];
await setupSessionRecordingInspector(page, (e) => rows.push(e));
await page.goto(`https://www.jetblue.com`, {
await page.goto(`https://www.hotjar.com`, {
waitUntil: "networkidle2",
});
await autoScroll(page);
Expand Down
3 changes: 1 addition & 2 deletions src/session-recording.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { Page } from 'puppeteer';
import url from 'url';
import { BlacklightEvent, SESSION_RECORDERS_LIST } from './types';

export const setupSessionRecordingInspector = async (page: Page, eventDataHandler: (event: BlacklightEvent) => void) => {
page.on('request', async request => {
const parsedUrl = url.parse(request.url());
const parsedUrl = new URL(request.url());
const cleanUrl = `${parsedUrl.hostname}${parsedUrl.pathname}`;
const stack = [
{
Expand Down

0 comments on commit d2ade34

Please sign in to comment.