Skip to content

Commit

Permalink
fix: issue 179 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
agoldis committed Sep 8, 2023
1 parent a3d70da commit cf8ca5d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 20 deletions.
2 changes: 1 addition & 1 deletion packages/cypress-cloud/lib/results/combine.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { parseISO } from "date-fns";
import * as _ from "lodash";
import _ from "lodash";
import { SpecResult } from "../runner/spec.type";
import { ExecutionState } from "../state";

Expand Down
2 changes: 1 addition & 1 deletion packages/cypress-cloud/lib/results/mapResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function getTestAttempt(
): CypressTestAttempt {
return {
...attempt,
startedAt: attempt.wallClockStartedAt,
startedAt: attempt.wallClockStartedAt ?? attempt.startedAt,
duration: attempt.wallClockDuration,
screenshots: screenshots.map(getScreenshot),
};
Expand Down
5 changes: 3 additions & 2 deletions packages/cypress-cloud/lib/results/results.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const getRunScreenshots = (
): ScreenshotArtifact[] => {
return tests.flatMap((test, i) =>
test.attempts.flatMap((a, ai) =>
a.screenshots.flatMap((s) => ({
(a.screenshots ?? []).flatMap((s) => ({
...s,
testId: `r${i}`,
testAttemptIndex: ai,
Expand Down Expand Up @@ -58,6 +58,7 @@ export const getInstanceResultPayload = (
runResult: CypressCommandLine.RunResult,
coverageFilePath?: string
): UpdateInstanceResultsPayload => {
debug("generating instance result payload from %o", runResult);
return {
stats: getStats(runResult.stats),
reporterStats: runResult.reporterStats,
Expand All @@ -66,7 +67,7 @@ export const getInstanceResultPayload = (
screenshots: getRunScreenshots(runResult.tests ?? []),
hasCoverage: !!coverageFilePath,
tests:
runResult.tests?.map((test, i) => ({
(runResult.tests ?? []).map((test, i) => ({
displayError: test.displayError,
state: test.state as TestState,
// @ts-ignore
Expand Down
20 changes: 4 additions & 16 deletions packages/cypress-cloud/lib/state/execution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ export type ScreenshotData = {
};

export class ExecutionState {
private attemptsData?: AttemptData[];
private screenshotsData?: ScreenshotData[];
private attemptsData: AttemptData[] = [];
private screenshotsData: ScreenshotData[] = [];
private currentTestID?: string;
private state: Record<InstanceId, InstanceExecutionState> = {};

Expand Down Expand Up @@ -199,12 +199,14 @@ export class ExecutionState {

// use spec:after results - it can become available before run results
if (i.specAfterResults) {
debug('Using spec:after results for %s "%s"', instanceId, i.spec);
return backfillException(
specResultsToCypressResults(configState, i.specAfterResults)
);
}

if (i.runResults) {
debug('Using runResults for %s "%s"', instanceId, i.spec);
return backfillException(i.runResults);
}

Expand All @@ -216,24 +218,14 @@ export class ExecutionState {
}

public setAttemptsData(attemptDetails: AttemptData) {
if (!this.attemptsData) {
this.attemptsData = [];
}
this.attemptsData.push(attemptDetails);
}

public getAttemptsData(): AttemptData[] | undefined {
return this.attemptsData;
}

public cleanAttemptsData() {
this.attemptsData = [];
}

public setScreenshotsData(screenshotsData: ScreenshotData) {
if (!this.screenshotsData) {
this.screenshotsData = [];
}
this.screenshotsData.push(screenshotsData);
}

Expand All @@ -248,8 +240,4 @@ export class ExecutionState {
public getCurrentTestID(): string | undefined {
return this.currentTestID;
}

public cleanScreenshotsData() {
this.screenshotsData = [];
}
}

0 comments on commit cf8ca5d

Please sign in to comment.