File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -139,7 +139,9 @@ jobs:
139139 cp -r cypress/screenshots artifacts 2>/dev/null || :
140140 cp -r cypress/videos artifacts 2>/dev/null || :
141141 cp -r cypress/reports/* artifacts || :
142+ ls -la ${{ env.E2E_RANCHER_LOG }} || echo ${{ env.E2E_RANCHER_LOG }} not found
142143 cp ${{ env.E2E_RANCHER_LOG }} artifacts/rancher.logs 2>/dev/null || :
144+ ls -la browser-logs/out.html || echo browser-logs/out.html not found
143145 cp browser-logs/out.html artifacts/browser-logs.html 2>/dev/null || :
144146
145147 - name : Upload Artifacts
Original file line number Diff line number Diff line change 22import { defineConfig } from 'cypress' ;
33import websocketTasks from './support/utils/webSocket-utils' ;
44import path from 'path' ;
5+ import fs from 'fs' ;
56const { removeDirectory } = require ( 'cypress-delete-downloads-folder' ) ;
67const { beforeRunHook, afterRunHook } = require ( 'cypress-mochawesome-reporter/lib' ) ;
78
@@ -168,6 +169,32 @@ const baseConfig = defineConfig({
168169
169170 // Done this way to catch errors when there are no tests run
170171 on ( 'after:run' , async ( ) => {
172+ // We need to wait for the cypress-terminal-report plugin to finish writing the browser logs
173+ // There's a race condition where the mochawesome afterRunHook can finish and exit the process
174+ // before the terminal report is written.
175+ const logFile = path . join ( config . projectRoot , 'browser-logs' , 'out.html' ) ;
176+ const timeout = 5000 ; // 5 seconds
177+ const interval = 100 ; // 100 ms
178+ let waited = 0 ;
179+ const fileExists = ( ) => {
180+ try {
181+ return fs . existsSync ( logFile ) ;
182+ } catch ( e ) {
183+ return false ;
184+ }
185+ } ;
186+
187+ const wait = ( ms : number ) => new Promise ( ( resolve ) => setTimeout ( resolve , ms ) ) ;
188+
189+ while ( waited < timeout && ! fileExists ( ) ) {
190+ await wait ( interval ) ;
191+ waited += interval ;
192+ }
193+
194+ if ( ! fileExists ( ) ) {
195+ console . warn ( `\n\n⚠️ Browser log file not found at ${ logFile } after ${ timeout } ms. Proceeding without it.\n\n` ) ;
196+ }
197+
171198 try {
172199 await afterRunHook ( ) ;
173200 } catch ( error ) {
You can’t perform that action at this time.
0 commit comments