# Instructions - Following Playwright test failed. - Explain why, be concise, respect Playwright best practices. - Provide a snippet of code with the fix, if possible. # Test info - Name: tssc/full_workflow.test.ts >> TSSC Complete Workflow >> Build Application Image >> should build application changes as new image through pipelines - Location: tests/tssc/full_workflow.test.ts:86:5 # Error details ``` Error: expect(received).toBe(expected) // Object.is equality Expected: true Received: false ``` # Test source ```ts 1 | import { CI } from '../../rhtap/core/integration/ci'; 2 | import { Pipeline } from '../../rhtap/core/integration/ci/pipeline'; 3 | import { expect } from '@playwright/test'; 4 | import { LoggerFactory, Logger } from '../../logger/logger'; 5 | 6 | const logger: Logger = LoggerFactory.getLogger('utils.test.assertion-helpers'); 7 | 8 | /** 9 | * Wraps an expect assertion for pipeline success and prints logs if the assertion fails 10 | * 11 | * @param pipeline The pipeline to check for success 12 | * @param ci The CI provider which can fetch logs for the pipeline 13 | * @returns Promise that resolves when the assertion is complete 14 | */ 15 | export async function expectPipelineSuccess(pipeline: Pipeline, ci: CI): Promise { 16 | try { > 17 | expect(pipeline.isSuccessful()).toBe(true); | ^ Error: expect(received).toBe(expected) // Object.is equality 18 | } catch (error) { 19 | // If the assertion failed, get and print the logs 20 | logger.info('🚨 Pipeline failed! Fetching pipeline logs...'); 21 | 22 | try { 23 | const logs = await ci.getPipelineLogs(pipeline); 24 | logger.info(`\n----- PIPELINE LOGS (${pipeline.getDisplayName()}) -----`); 25 | logger.info(logs); 26 | logger.info('----- END PIPELINE LOGS -----\n'); 27 | } catch (logError) { 28 | logger.error(`Error retrieving pipeline logs: ${logError}`); 29 | } 30 | 31 | // Re-throw the original error so the test still fails 32 | throw error; 33 | } 34 | } 35 | 36 | /** 37 | * Generic function to wrap any expect assertion with additional error handling 38 | * 39 | * @param assertion Function that performs the assertion 40 | * @param errorHandler Function called if the assertion fails (before re-throwing the error) 41 | * @returns Promise that resolves when the assertion is complete 42 | */ 43 | export async function expectWithErrorHandler( 44 | assertion: () => T | Promise, 45 | errorHandler: (error: Error) => void | Promise 46 | ): Promise { 47 | try { 48 | return await assertion(); 49 | } catch (error) { 50 | if (error instanceof Error) { 51 | await errorHandler(error); 52 | } else { 53 | await errorHandler(new Error(String(error))); 54 | } 55 | throw error; 56 | } 57 | } 58 | 59 | /** 60 | * Specifically for Tekton pipelines - checks if a pipeline is successful, 61 | * and if not, fetches and prints detailed logs 62 | * 63 | * @param pipeline The Tekton pipeline to check 64 | * @param tektonCI The TektonCI instance to use to fetch logs 65 | * @returns Promise resolving to true if pipeline was successful, false otherwise 66 | */ 67 | export async function checkTektonPipelineWithLogs( 68 | pipeline: Pipeline, 69 | tektonCI: any 70 | ): Promise { 71 | const isSuccessful = pipeline.isSuccessful(); 72 | 73 | if (!isSuccessful) { 74 | logger.info(`🚨 Tekton pipeline ${pipeline.getDisplayName()} failed!`); 75 | logger.info(`Status: ${pipeline.status}`); 76 | 77 | try { 78 | const logsUrl = await tektonCI.getPipelineLogs(pipeline); 79 | logger.info('\n----- TEKTON PIPELINE DETAILS -----'); 80 | logger.info(`Pipeline name: ${pipeline.name}`); 81 | logger.info(`Repository: ${pipeline.repositoryName}`); 82 | logger.info(`Logs URL: ${logsUrl}`); 83 | if (pipeline.results) { 84 | logger.info(`Results: ${pipeline.results}`); 85 | } 86 | logger.info('----- END PIPELINE DETAILS -----\n'); 87 | } catch (logError) { 88 | logger.error(`Error retrieving Tekton pipeline logs: ${logError}`); 89 | } 90 | } 91 | 92 | return isSuccessful; 93 | } 94 | ```