Skip to content

Commit a16e253

Browse files
author
rocketraccoon
committed
feat(save-history-mode): fix save history mode #1
1 parent d2fa1ec commit a16e253

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

src/browser/history/index.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ interface RunWithHistoryHooksData<T> extends HooksData {
5151
fn: () => T;
5252
}
5353

54+
export const DISABLE_OVERWRITE = "disable_overwrite";
55+
5456
export const runWithoutHistory = async <T>(
5557
{ callstack }: { callstack: HooksData["callstack"] },
5658
fn: () => T,
@@ -68,11 +70,7 @@ const skipNode = (callstack: Callstack, nodeData: NodeData): boolean => {
6870
return true;
6971
}
7072

71-
if (nodeData.name === "execute" && nodeData?.args[0]?.toString().includes("@disable-overwrite")) {
72-
return true;
73-
}
74-
75-
return false;
73+
return nodeData?.args[1] === DISABLE_OVERWRITE;
7674
};
7775

7876
const runWithHistoryHooks = <T>({ session, callstack, nodeData, fn, config }: RunWithHistoryHooksData<T>): T => {

src/browser/history/rrweb.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import { eventWithTime } from "@rrweb/types";
33
import { MasterEvents } from "../../events";
44
import { SnapshotsData, TestContext } from "../../types";
55
import path from "path";
6+
import { DISABLE_OVERWRITE } from "./";
67

78
const rrwebCode = fs.readFileSync(path.join(__dirname, "../client-scripts/rrweb-record.min.js"), "utf-8");
89

910
export async function installRrwebAndCollectEvents(session: WebdriverIO.Browser): Promise<eventWithTime[]> {
1011
/* eslint-disable @typescript-eslint/ban-ts-comment */
1112
return session.execute(
12-
(rrwebRecordFnCode, serverTime) => {
13-
// @disable-overwrite
13+
(_, rrwebRecordFnCode, serverTime) => {
1414
// @ts-expect-error
1515
if (!window.__testplaneTiming) {
1616
// @ts-expect-error
@@ -91,6 +91,7 @@ export async function installRrwebAndCollectEvents(session: WebdriverIO.Browser)
9191

9292
return result;
9393
},
94+
DISABLE_OVERWRITE,
9495
rrwebCode,
9596
Date.now(),
9697
);

0 commit comments

Comments
 (0)