Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e-test: add terminal and console contents to e2e logs #6115

Merged
merged 5 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions test/e2e/pages/console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
17 changes: 17 additions & 0 deletions test/e2e/pages/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,21 @@ export class Terminal {
}
}, text);
}

async logTerminalContents() {
const terminalRows = this.code.driver.page.locator('.xterm-rows > div');
const terminalContents = (await terminalRows.evaluateAll((rows) =>
rows.map((row) => {
const spans = row.querySelectorAll('span');
return Array.from(spans)
.map((span) => span.textContent?.trim() || '')
.join(' ');
})
)).filter((line) => line && line.length > 0)
.join('\n');

this.code.logger.log('---- START: Terminal Contents ----');
this.code.logger.log(terminalContents);
this.code.logger.log('---- END: Terminal Contents ----');
}
}
5 changes: 4 additions & 1 deletion test/e2e/tests/_test.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ export const test = base.extend<TestFixtures, WorkerFixtures>({
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('');
Expand All @@ -302,6 +302,9 @@ export const test = base.extend<TestFixtures, WorkerFixtures>({

await use();

await app.workbench.console.logConsoleContents();
await app.workbench.terminal.logTerminalContents();

const failed = testInfo.status !== testInfo.expectedStatus;
const testTitle = testInfo.title;
const endLog = failed ? `>>> !!! FAILURE !!! Test end: '${testTitle}' !!! FAILURE !!! <<<` : `>>> Test end: '${testTitle}' <<<`;
Expand Down
Loading