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