Skip to content

Commit

Permalink
fix: correctly mock "debug", "saveScreenshot" and "savePDF"
Browse files Browse the repository at this point in the history
  • Loading branch information
DudaGod committed Apr 16, 2024
1 parent 7e4c1c8 commit 0b25eee
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/runner/browser-env/vite/browser-modules/driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import { BrowserEventNames } from "./types.js";
type ProtocolCommandFn = (...args: unknown[]) => Promise<unknown>;
type PropertiesObject = Record<string, PropertyDescriptor>;

const SERVER_HANDLED_COMMANDS = ["debug", "saveScreenshot", "savePDF"];

export default class ProxyDriver {
static newSession(
params: Record<string, unknown>,
Expand Down Expand Up @@ -65,10 +67,13 @@ function getAllProtocolCommands(): string[] {
}

function getMockedProtocolCommands(): PropertiesObject {
return [...getAllProtocolCommands(), ...window.__testplane__.customCommands].reduce((acc, commandName) => {
acc[commandName] = { value: mockCommand(commandName) };
return acc;
}, {} as PropertiesObject);
return [...getAllProtocolCommands(), ...SERVER_HANDLED_COMMANDS, ...window.__testplane__.customCommands].reduce(
(acc, commandName) => {
acc[commandName] = { value: mockCommand(commandName) };
return acc;
},
{} as PropertiesObject,
);
}

function mockCommand(commandName: string): ProtocolCommandFn {
Expand Down

0 comments on commit 0b25eee

Please sign in to comment.