diff --git a/test/e2e/pages/console.ts b/test/e2e/pages/console.ts index c8f71bb125b..2ae1234f9c6 100644 --- a/test/e2e/pages/console.ts +++ b/test/e2e/pages/console.ts @@ -107,11 +107,10 @@ export class Console { } async logConsoleContents() { - this.code.logger.log('------------------'); - this.code.logger.log('Console contents:'); - this.code.logger.log('------------------'); + this.code.logger.log('---- START: Console Contents ----'); const contents = await this.code.driver.page.locator(CONSOLE_LINES).allTextContents(); contents.forEach(line => this.code.logger.log(line)); + this.code.logger.log('---- END: Console Contents ----'); } async typeToConsole(text: string, delay = 30, pressEnter = false) { diff --git a/test/e2e/pages/terminal.ts b/test/e2e/pages/terminal.ts index 586c3517520..5a1327eb082 100644 --- a/test/e2e/pages/terminal.ts +++ b/test/e2e/pages/terminal.ts @@ -70,4 +70,23 @@ export class Terminal { } }, text); } + + async logTerminalContents() { + const plainText = await this.code.driver.page.evaluate(() => { + const rows = document.querySelectorAll('.xterm-rows > div'); + return Array.from(rows) + .map((row) => { + const spans = row.querySelectorAll('span'); + return Array.from(spans) + .map((span) => span.textContent?.trim() || '') + .join(' '); // Join spans within a row with a space + }) + .filter((line) => line && line.length > 0) // Remove empty lines + .join('\n'); // Join rows with newlines + }); + + this.code.logger.log('---- START: Terminal Contents ----'); + this.code.logger.log(plainText); + this.code.logger.log('---- END: Terminal Contents ----'); + } } diff --git a/test/e2e/tests/_test.setup.ts b/test/e2e/tests/_test.setup.ts index 5c6580ebffe..8082fc18b42 100644 --- a/test/e2e/tests/_test.setup.ts +++ b/test/e2e/tests/_test.setup.ts @@ -293,7 +293,7 @@ export const test = base.extend({ await use(app.code.driver.page); }, - autoTestFixture: [async ({ logger, suiteId }, use, testInfo) => { + autoTestFixture: [async ({ logger, suiteId, app }, use, testInfo) => { if (!suiteId) { throw new Error('suiteId is required'); } logger.log(''); @@ -306,6 +306,9 @@ export const test = base.extend({ const testTitle = testInfo.title; const endLog = failed ? `>>> !!! FAILURE !!! Test end: '${testTitle}' !!! FAILURE !!! <<<` : `>>> Test end: '${testTitle}' <<<`; + await app.workbench.console.logConsoleContents(); + await app.workbench.terminal.logTerminalContents(); + logger.log(''); logger.log(endLog); logger.log('');