From 30298c0991ba6c78abb2912e87d670d926cdf0b7 Mon Sep 17 00:00:00 2001 From: Bart Onstee Date: Wed, 20 Nov 2024 13:18:53 +0000 Subject: [PATCH] Update cli.js --- bin/cli.js | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/bin/cli.js b/bin/cli.js index f5b53f8..7065869 100755 --- a/bin/cli.js +++ b/bin/cli.js @@ -1493,6 +1493,8 @@ 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, @@ -1550,6 +1552,8 @@ 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 { @@ -1575,6 +1579,7 @@ var SpecAfterResult = class _SpecAfterResult { ) }; } + //////////////////// att3mpts static getTestStandard(specAfterResults, attempts) { const standardTestList = (specAfterResults.tests ?? []).map((test, i) => { const mochaAttempts = attempts.filter( @@ -1593,14 +1598,16 @@ var SpecAfterResult = class _SpecAfterResult { } ); return { - body: "body" in test ? test.body : mochaAttempts[0]?.body ?? "", - testId: "testId" in test ? test.testId : mochaAttempts[0]?.id ?? `r${i}`, + body: "body" in test ? test.body : "", + testId: `r${i}`, title: test.title, displayError: test.displayError, state: test.state, - attempts: standardAttempts + attempts: test.attempts }; }); + console.info('standardTestList: ') + console.info(JSON.stringify(standardTestList)) return standardTestList; } static getSpecStandard(spec) { @@ -1676,7 +1683,7 @@ var ModuleAPIResults = class _ModuleAPIResults { const runScreenshotPaths = _ModuleAPIResults.getRunScreenshots(run2).map( (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( (cypressAttempt, j) => { const mochaAttempt = mochaAttempts.find( @@ -1685,6 +1692,7 @@ var ModuleAPIResults = class _ModuleAPIResults { const attemptScreenshots = testScreenshots.filter( (t) => t.testAttemptIndex === j ); + ////////// belangrijk Bart return _ModuleAPIResults.getTestAttempt( mochaAttempt ?? null, cypressAttempt, @@ -1708,13 +1716,14 @@ var ModuleAPIResults = class _ModuleAPIResults { */ static getTestAttempt(mochaAttempt, cypressAttempt, screenshots, specStartedAt) { if (!mochaAttempt) { + //console.info(cypressAttempt.state); return { state: cypressAttempt.state, - error: "error" in cypressAttempt ? cypressAttempt.error : SpecAfterResult.getDummyTestAttemptError(cypressAttempt.state), + error: "error", 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" in cypressAttempt ? cypressAttempt.screenshots : screenshots + screenshots: screenshots }; } return { @@ -2368,6 +2377,8 @@ var StandardResultsToAPIResults = class _StandardResultsToAPIResults { }; } static getAllScreenshots(run2) { + ///////////////////////// get screenshots + //console.info(run2); return (run2.tests ?? []).flatMap( (t, i) => t.attempts.flatMap( (a, j) => a.screenshots.map((s) => ({ @@ -2392,12 +2403,17 @@ 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"); } const instanceResults = getInstanceResultPayload(run2, coverageFilePath); const instanceTests = getInstanceTestsPayload(run2, configState); + //////////////////// just before screenshotuploadurl call const { videoUploadUrl, screenshotUploadUrls, coverageUploadUrl, cloud } = await reportResults(instanceId, instanceTests, instanceResults); if (cloud?.shouldCancel) { debug14("instance %s should cancel", instanceId); @@ -2422,6 +2438,8 @@ async function getReportResultsTask(instanceId, executionState, configState, std ]); } async function reportResults(instanceId, instanceTests, instanceResults) { + + ///////////report results debug14("reporting instance %s results...", instanceId); if (isCc()) { return reportInstanceResultsMerged(instanceId, { @@ -2756,6 +2774,7 @@ var import_debug22 = __toESM(require("debug")); var import_getos = __toESM(require("getos")); var import_os = require("os"); var import_util2 = require("util"); +const cypress = require("cypress"); var debug20 = (0, import_debug22.default)("cc:platform"); var getOsVersion = async () => { if ((0, import_os.platform)() === "linux") { @@ -3030,14 +3049,13 @@ var SpecAfterToModuleAPIMapper = class _SpecAfterToModuleAPIMapper { }; } static getTest(t, screenshots) { + /////////////////////// hierrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr BART return { ...t, attempts: t.attempts.map( (a, i) => _SpecAfterToModuleAPIMapper.getTestAttempt( a, - screenshots.filter( - (s) => s.testId === t.testId && s.testAttemptIndex === i - ) + screenshots ) ) }; @@ -3219,6 +3237,7 @@ var ExecutionState = class { i.runResultsReportedAt = new Date(); } getInstanceResults(configState, instanceId) { + console.info('BART') const i = this.getInstance(instanceId); if (!i) { error('Cannot find execution state for instance "%s"', instanceId); @@ -3229,6 +3248,7 @@ 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) );