Bugfixes cli.js screenshots and flaky test
This commit is contained in:
50
bin/cli.js
50
bin/cli.js
@@ -1493,8 +1493,6 @@ var SpecAfterResult = class _SpecAfterResult {
|
||||
* @returns unified results, including attempts and screenshot details
|
||||
*/
|
||||
static getSpecAfterStandard(specAfterResults, executionState) {
|
||||
console.info('executionState: ')
|
||||
console.info(executionState)
|
||||
return {
|
||||
error: specAfterResults.error,
|
||||
hooks: null,
|
||||
@@ -1540,7 +1538,7 @@ var SpecAfterResult = class _SpecAfterResult {
|
||||
static getDummyTestAttemptError(attemptState) {
|
||||
return (0, import_ts_pattern4.match)(attemptState).with("failed", () => ({
|
||||
name: "Error",
|
||||
message: "[@bart/cc] Could not get cypress attempt error details",
|
||||
message: "[@bart/cc] Cypress CLI did not share error details",
|
||||
stack: "",
|
||||
codeFrame: null
|
||||
})).with("skipped", () => ({
|
||||
@@ -1552,8 +1550,6 @@ var SpecAfterResult = class _SpecAfterResult {
|
||||
}
|
||||
static getTestAttemptStandard(mochaAttempt, cypressAttempt, specStartedAt) {
|
||||
if (!mochaAttempt) {
|
||||
console.info('gettestattemptstandard: ')
|
||||
console.info(cypressAttempt)
|
||||
const error2 = "error" in cypressAttempt ? cypressAttempt.error : null;
|
||||
const duration = "wallClockDuration" in cypressAttempt ? cypressAttempt.wallClockDuration : null;
|
||||
return {
|
||||
@@ -1598,18 +1594,17 @@ var SpecAfterResult = class _SpecAfterResult {
|
||||
}
|
||||
);
|
||||
return {
|
||||
body: "body" in test ? test.body : "",
|
||||
testId: `r${i}`,
|
||||
body: "body" in test ? test.body : mochaAttempts[0]?.body ?? "",
|
||||
testId: "testId" in test ? test.testId : mochaAttempts[0]?.id ?? `r${i}`,
|
||||
title: test.title,
|
||||
displayError: test.displayError,
|
||||
state: test.state,
|
||||
attempts: test.attempts
|
||||
attempts: standardAttempts
|
||||
};
|
||||
});
|
||||
console.info('standardTestList: ')
|
||||
console.info(JSON.stringify(standardTestList))
|
||||
return standardTestList;
|
||||
}
|
||||
|
||||
static getSpecStandard(spec) {
|
||||
return {
|
||||
name: spec.name,
|
||||
@@ -1692,7 +1687,6 @@ var ModuleAPIResults = class _ModuleAPIResults {
|
||||
const attemptScreenshots = testScreenshots.filter(
|
||||
(t) => t.testAttemptIndex === j
|
||||
);
|
||||
////////// belangrijk Bart
|
||||
return _ModuleAPIResults.getTestAttempt(
|
||||
mochaAttempt ?? null,
|
||||
cypressAttempt,
|
||||
@@ -1716,14 +1710,13 @@ var ModuleAPIResults = class _ModuleAPIResults {
|
||||
*/
|
||||
static getTestAttempt(mochaAttempt, cypressAttempt, screenshots, specStartedAt) {
|
||||
if (!mochaAttempt) {
|
||||
//console.info(cypressAttempt.state);
|
||||
return {
|
||||
state: cypressAttempt.state,
|
||||
error: "error",
|
||||
error: "error" in cypressAttempt ? cypressAttempt.error : SpecAfterResult.getDummyTestAttemptError(cypressAttempt.state),
|
||||
startedAt: "startedAt" in cypressAttempt ? cypressAttempt.startedAt : ( new Date()).toISOString(),
|
||||
duration: "duration" in cypressAttempt ? cypressAttempt.duration : 0,
|
||||
videoTimestamp: "videoTimestamp" in cypressAttempt ? cypressAttempt.videoTimestamp : 0,
|
||||
screenshots: screenshots
|
||||
screenshots: cypressAttempt.state == "failed" ? screenshots : cypressAttempt.screenshots
|
||||
};
|
||||
}
|
||||
return {
|
||||
@@ -2378,15 +2371,26 @@ var StandardResultsToAPIResults = class _StandardResultsToAPIResults {
|
||||
}
|
||||
static getAllScreenshots(run2) {
|
||||
///////////////////////// get screenshots
|
||||
//console.info(run2);
|
||||
return (run2.tests ?? []).flatMap(
|
||||
(t, i) => t.attempts.flatMap(
|
||||
if (!run2.tests) {
|
||||
return [];
|
||||
}
|
||||
const filtattempts = [];
|
||||
|
||||
run2.tests.map((test) => {
|
||||
test.attempts.map((attempt) => {
|
||||
if (attempt.state === 'failed') {
|
||||
filtattempts.push(attempt);
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
return filtattempts.flatMap(
|
||||
(a, j) => a.screenshots.map((s) => ({
|
||||
...s,
|
||||
testId: `r${i}`,
|
||||
testId: `r${j}`,
|
||||
testAttemptIndex: j,
|
||||
screenshotId: getRandomString()
|
||||
}))
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -2403,10 +2407,6 @@ var StandardResultsToAPIResults = class _StandardResultsToAPIResults {
|
||||
var debug14 = (0, import_debug16.default)("cc:results");
|
||||
async function getReportResultsTask(instanceId, executionState, configState, stdout2, coverageFilePath) {
|
||||
const results = executionState.getInstanceResults(configState, instanceId);
|
||||
console.info("///////executionState: " + JSON.stringify(executionState));
|
||||
console.info("///////results: " + JSON.stringify(results));
|
||||
console.info("///////runs: " + JSON.stringify(results.runs))
|
||||
console.info("///////tests: " + JSON.stringify(results.runs[0].tests))
|
||||
const run2 = results.runs[0];
|
||||
if (!run2) {
|
||||
throw new Error("No run found in Cypress results");
|
||||
@@ -2775,6 +2775,7 @@ var import_getos = __toESM(require("getos"));
|
||||
var import_os = require("os");
|
||||
var import_util2 = require("util");
|
||||
const cypress = require("cypress");
|
||||
const { attempt } = require("lodash");
|
||||
var debug20 = (0, import_debug22.default)("cc:platform");
|
||||
var getOsVersion = async () => {
|
||||
if ((0, import_os.platform)() === "linux") {
|
||||
@@ -3248,7 +3249,6 @@ var ExecutionState = class {
|
||||
}
|
||||
if (i.specAfterResults) {
|
||||
debug22('Using spec:after results for %s "%s"', instanceId, i.spec);
|
||||
console.info(i.specAfterResults)
|
||||
return SpecAfterToModuleAPIMapper.backfillException(
|
||||
SpecAfterToModuleAPIMapper.convert(i.specAfterResults, configState)
|
||||
);
|
||||
@@ -3657,4 +3657,4 @@ main().then((result) => {
|
||||
console.error(err);
|
||||
}
|
||||
process.exit(1);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user