Skip to content

Commit

Permalink
fix: fixed cypress 12 compatibility tests
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelangarano committed Sep 26, 2023
1 parent dd41486 commit b404c45
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion e2e/cypress-compatibility/__tests__/run.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, jest } from "@jest/globals";
import { fetchRun, runCypressCloud } from "../../utils/utils";
import { fetchRun, runCypressCloud } from "../utils/utils";

import { data as apiReference } from "../data-references/ccy-1.9.4-cy-12-crapi";
import { all, config, specs } from "../data-references/ccy-1.9.4-cy-12-cycl";
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions packages/cypress-cloud/lib/cypress.types/12.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export namespace Cypress12 {
videoTimestamp: number;
wallClockDuration: number;
wallClockStartedAt: string;
startedAt: string;
}

export interface TestError {
Expand Down
2 changes: 1 addition & 1 deletion packages/cypress-cloud/lib/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const getGitInfo = async (projectRoot: string) => {
const commitInfo = await git.commitInfo(projectRoot);
return getCommitDefaults({
branch: commitInfo.branch,
remoteOrigin: commitInfo.remote,
remoteOrigin: commitInfo.remote ?? 'null',
authorEmail: commitInfo.email,
authorName: commitInfo.author,
message: commitInfo.message,
Expand Down
20 changes: 13 additions & 7 deletions packages/cypress-cloud/lib/results/specAfterResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { MochaError } from "../cypress.types/shared";
import { warn } from "../log";
import { getRandomString } from "../nano";
import { ExecutionState, ExecutionStateTestAttempt } from "../state";
import { _cypressVersion } from "../state/global";

export class SpecAfterResult {
/**
Expand Down Expand Up @@ -104,6 +105,7 @@ export class SpecAfterResult {
"wallClockDuration" in cypressAttempt
? cypressAttempt.wallClockDuration
: null;

return {
state: cypressAttempt.state,
error: error
Expand All @@ -112,17 +114,20 @@ export class SpecAfterResult {
timings: "timings" in cypressAttempt ? cypressAttempt.timings : null,
wallClockStartedAt:
"wallClockStartedAt" in cypressAttempt
? cypressAttempt.wallClockStartedAt
? (cypressAttempt.wallClockStartedAt ?? new Date().toISOString())
: new Date().toISOString(),
startedAt:
"startedAt" in cypressAttempt
? (cypressAttempt.startedAt ?? new Date().toISOString())
: new Date().toISOString(),

wallClockDuration: duration ? duration : 0,
failedFromHookId:
"failedFromHookId" in cypressAttempt
? cypressAttempt.failedFromHookId
: null,
videoTimestamp:
"videoTimestamp" in cypressAttempt
? cypressAttempt.videoTimestamp
? (cypressAttempt.videoTimestamp ?? 0)
: 0,
};
}
Expand All @@ -140,6 +145,7 @@ export class SpecAfterResult {
wallClockStartedAt:
mochaAttempt.wallClockStartedAt ?? new Date().toISOString(),
wallClockDuration: mochaAttempt.duration ?? -1,
startedAt: mochaAttempt.wallClockStartedAt,
failedFromHookId:
"failedFromHookId" in cypressAttempt
? cypressAttempt.failedFromHookId
Expand All @@ -148,9 +154,9 @@ export class SpecAfterResult {
"videoTimestamp" in cypressAttempt
? cypressAttempt.videoTimestamp
: SpecAfterResult.getAttemptVideoTimestamp(
parseISO(mochaAttempt.wallClockStartedAt).getTime(),
specStartedAt.getTime()
),
parseISO(mochaAttempt.wallClockStartedAt).getTime(),
specStartedAt.getTime()
),
};
}

Expand Down Expand Up @@ -195,7 +201,7 @@ export class SpecAfterResult {
spec: CypressTypes.EventPayload.SpecAfter.Spec
): Standard.SpecAfter.Spec {
return {
name: spec.name,
name: parseFloat(_cypressVersion!) >= 13 ? spec.name : ("baseName" in spec ? spec.baseName : ""),
relative: spec.relative,
absolute: spec.absolute,
fileExtension: spec.fileExtension,
Expand Down

0 comments on commit b404c45

Please sign in to comment.