Update cli.js

This commit is contained in:
2024-11-20 13:18:53 +00:00
parent ff2ae0a5c6
commit 30298c0991

View File

@@ -1493,6 +1493,8 @@ 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,
@@ -1550,6 +1552,8 @@ 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 {
@@ -1575,6 +1579,7 @@ var SpecAfterResult = class _SpecAfterResult {
) )
}; };
} }
//////////////////// att3mpts
static getTestStandard(specAfterResults, attempts) { static getTestStandard(specAfterResults, attempts) {
const standardTestList = (specAfterResults.tests ?? []).map((test, i) => { const standardTestList = (specAfterResults.tests ?? []).map((test, i) => {
const mochaAttempts = attempts.filter( const mochaAttempts = attempts.filter(
@@ -1593,14 +1598,16 @@ var SpecAfterResult = class _SpecAfterResult {
} }
); );
return { return {
body: "body" in test ? test.body : mochaAttempts[0]?.body ?? "", body: "body" in test ? test.body : "",
testId: "testId" in test ? test.testId : mochaAttempts[0]?.id ?? `r${i}`, testId: `r${i}`,
title: test.title, title: test.title,
displayError: test.displayError, displayError: test.displayError,
state: test.state, state: test.state,
attempts: standardAttempts attempts: test.attempts
}; };
}); });
console.info('standardTestList: ')
console.info(JSON.stringify(standardTestList))
return standardTestList; return standardTestList;
} }
static getSpecStandard(spec) { static getSpecStandard(spec) {
@@ -1676,7 +1683,7 @@ var ModuleAPIResults = class _ModuleAPIResults {
const runScreenshotPaths = _ModuleAPIResults.getRunScreenshots(run2).map( const runScreenshotPaths = _ModuleAPIResults.getRunScreenshots(run2).map(
(i2) => i2.path (i2) => i2.path
); );
const testScreenshots = executionState.getScreenshotsData().filter((s) => runScreenshotPaths.includes(s.path)).filter((s) => s.testId === testId); const testScreenshots = executionState.getScreenshotsData();
const standardAttempts = (test.attempts ?? []).map( const standardAttempts = (test.attempts ?? []).map(
(cypressAttempt, j) => { (cypressAttempt, j) => {
const mochaAttempt = mochaAttempts.find( const mochaAttempt = mochaAttempts.find(
@@ -1685,6 +1692,7 @@ 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,
@@ -1708,13 +1716,14 @@ 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" in cypressAttempt ? cypressAttempt.error : SpecAfterResult.getDummyTestAttemptError(cypressAttempt.state), error: "error",
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" in cypressAttempt ? cypressAttempt.screenshots : screenshots screenshots: screenshots
}; };
} }
return { return {
@@ -2368,6 +2377,8 @@ var StandardResultsToAPIResults = class _StandardResultsToAPIResults {
}; };
} }
static getAllScreenshots(run2) { static getAllScreenshots(run2) {
///////////////////////// get screenshots
//console.info(run2);
return (run2.tests ?? []).flatMap( return (run2.tests ?? []).flatMap(
(t, i) => t.attempts.flatMap( (t, i) => t.attempts.flatMap(
(a, j) => a.screenshots.map((s) => ({ (a, j) => a.screenshots.map((s) => ({
@@ -2392,12 +2403,17 @@ 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");
} }
const instanceResults = getInstanceResultPayload(run2, coverageFilePath); const instanceResults = getInstanceResultPayload(run2, coverageFilePath);
const instanceTests = getInstanceTestsPayload(run2, configState); const instanceTests = getInstanceTestsPayload(run2, configState);
//////////////////// just before screenshotuploadurl call
const { videoUploadUrl, screenshotUploadUrls, coverageUploadUrl, cloud } = await reportResults(instanceId, instanceTests, instanceResults); const { videoUploadUrl, screenshotUploadUrls, coverageUploadUrl, cloud } = await reportResults(instanceId, instanceTests, instanceResults);
if (cloud?.shouldCancel) { if (cloud?.shouldCancel) {
debug14("instance %s should cancel", instanceId); debug14("instance %s should cancel", instanceId);
@@ -2422,6 +2438,8 @@ async function getReportResultsTask(instanceId, executionState, configState, std
]); ]);
} }
async function reportResults(instanceId, instanceTests, instanceResults) { async function reportResults(instanceId, instanceTests, instanceResults) {
///////////report results
debug14("reporting instance %s results...", instanceId); debug14("reporting instance %s results...", instanceId);
if (isCc()) { if (isCc()) {
return reportInstanceResultsMerged(instanceId, { return reportInstanceResultsMerged(instanceId, {
@@ -2756,6 +2774,7 @@ var import_debug22 = __toESM(require("debug"));
var import_getos = __toESM(require("getos")); 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");
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") {
@@ -3030,14 +3049,13 @@ var SpecAfterToModuleAPIMapper = class _SpecAfterToModuleAPIMapper {
}; };
} }
static getTest(t, screenshots) { static getTest(t, screenshots) {
/////////////////////// hierrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr BART
return { return {
...t, ...t,
attempts: t.attempts.map( attempts: t.attempts.map(
(a, i) => _SpecAfterToModuleAPIMapper.getTestAttempt( (a, i) => _SpecAfterToModuleAPIMapper.getTestAttempt(
a, a,
screenshots.filter( screenshots
(s) => s.testId === t.testId && s.testAttemptIndex === i
)
) )
) )
}; };
@@ -3219,6 +3237,7 @@ var ExecutionState = class {
i.runResultsReportedAt = new Date(); i.runResultsReportedAt = new Date();
} }
getInstanceResults(configState, instanceId) { getInstanceResults(configState, instanceId) {
console.info('BART')
const i = this.getInstance(instanceId); const i = this.getInstance(instanceId);
if (!i) { if (!i) {
error('Cannot find execution state for instance "%s"', instanceId); error('Cannot find execution state for instance "%s"', instanceId);
@@ -3229,6 +3248,7 @@ 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)
); );