Skip to content

Commit

Permalink
chore: ..
Browse files Browse the repository at this point in the history
  • Loading branch information
agoldis committed Sep 17, 2023
1 parent afb690a commit f32a1d5
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 42 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
getInstanceResultPayload,
getInstanceTestsPayload,
getTestAttempt,
} from "../api";
import { getInstanceResultPayload, getInstanceTestsPayload } from "../api";
import configException from "./fixtures/payloads/cypressResult/exception/config.json";
import rawResultException from "./fixtures/payloads/cypressResult/exception/results.json";

Expand Down
39 changes: 4 additions & 35 deletions packages/cypress-cloud/lib/results/empty.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,6 @@
import { Standard } from "../cypress.types";
import { ConfigState } from "../state";

/**
* Generates a fake test item from an exception
*
* @param error
* @param stats
* @returns
*/
export function getFakeTestFromException(
error: string,
stats: Standard.ModuleAPI.Run["stats"]
): Standard.ModuleAPI.Test {
return {
title: ["Unknown"],
body: "",
displayError: error.split("\n")[0],
state: "failed",
attempts: [
{
state: "failed",
duration: 0,
error: {
name: "Error",
message: error.split("\n")[0],
stack: error,
codeFrame: null,
},
screenshots: [],
startedAt: stats.startedAt,
videoTimestamp: 0,
},
],
};
}

export const emptyStats = {
totalDuration: 0,
totalSuites: 0,
Expand All @@ -45,7 +11,10 @@ export const emptyStats = {
totalTests: 0,
};

const getDummyFailedTest = (start: string, error: string) => ({
const getDummyFailedTest = (
start: string,
error: string
): Standard.ModuleAPI.Test => ({
title: ["Unknown"],
state: "failed",
body: "// This test is automatically generated due to execution failure",
Expand Down
35 changes: 34 additions & 1 deletion packages/cypress-cloud/lib/results/mapResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import { Standard } from "../cypress.types";
import { ConfigState } from "../state";
import { getFakeTestFromException } from "./empty";

export class SpecAfterToModuleAPIMapper {
static getTestAttempt(
Expand Down Expand Up @@ -106,3 +105,37 @@ export class SpecAfterToModuleAPIMapper {
};
}
}

/**
* Generates a fake test item from an exception
*
* @param error
* @param stats
* @returns
*/
function getFakeTestFromException(
error: string,
stats: Standard.ModuleAPI.Run["stats"]
): Standard.ModuleAPI.Test {
return {
title: ["Unknown"],
body: "",
displayError: error.split("\n")[0],
state: "failed",
attempts: [
{
state: "failed",
duration: 0,
error: {
name: "Error",
message: error.split("\n")[0],
stack: error,
codeFrame: null,
},
screenshots: [],
startedAt: stats.startedAt,
videoTimestamp: 0,
},
],
};
}
2 changes: 1 addition & 1 deletion packages/cypress-cloud/lib/state/execution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export class ExecutionState {

return getFailedFakeInstanceResult(configState, {
specs: ["unknown"],
error: "Cannot find execution state for instance",
error: `[currents] Error while processing cypress results for instance ${instanceId}. See the console output for details.`,
});
}

Expand Down

0 comments on commit f32a1d5

Please sign in to comment.