Skip to content

Commit

Permalink
Ignore replay-connect callback event
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanjduffy committed Dec 26, 2023
1 parent 7625e89 commit c64866b
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions packages/cypress/src/support.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,27 @@ let gPluginServer: WebSocket | undefined;
// user-facing
const COMMAND_IGNORE_LIST = ["log-restore", "within-restore", "end-logGroup"];

function handleReplayConnectResponse(v: unknown) {
if (v && typeof v === "object" && "port" in v && typeof v.port === "number") {
gServerPort = v.port;
} else {
cy.log("[replay.io] Received unexpected response when connecting to plugin");
}
}

function shouldIgnoreCommand(cmd: Cypress.EnqueuedCommand | Cypress.CommandQueue) {
if (isCommandQueue(cmd)) {
cmd = cmd.toJSON() as any as Cypress.EnqueuedCommand;
}

if (
cmd.name === "then" &&
Array.isArray(cmd.args) &&
cmd.args[0] === handleReplayConnectResponse
) {
return true;
}

return COMMAND_IGNORE_LIST.includes(cmd.name);
}

Expand Down Expand Up @@ -618,13 +634,7 @@ export default function register() {

before(() => {
if (gServerPort == null) {
cy.task(CONNECT_TASK_NAME, null, { log: false }).then(v => {
if (v && typeof v === "object" && "port" in v && typeof v.port === "number") {
gServerPort = v.port;
} else {
cy.log("[replay.io] Received unexpected response when connecting to plugin");
}
});
cy.task(CONNECT_TASK_NAME, null, { log: false }).then(handleReplayConnectResponse);
}
});
beforeEach(() => {
Expand Down

0 comments on commit c64866b

Please sign in to comment.