feat: make it possible to filter by column in HTML report (#27020)

This commit is contained in:
Max Schmitt 2023-09-12 22:13:15 +02:00 committed by GitHub
parent 700b310150
commit d0945192a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 2 deletions

View File

@ -113,6 +113,7 @@ export class Filter {
status: status as any,
file: test.location.file,
line: String(test.location.line),
column: String(test.location.column),
};
(test as any).searchValues = searchValues;
}
@ -132,8 +133,8 @@ export class Filter {
for (const text of this.text) {
if (searchValues.text.includes(text))
continue;
const location = text.split(':');
if (location.length === 2 && searchValues.file.includes(location[0]) && searchValues.line.includes(location[1]))
const [fileName, line, column] = text.split(':');
if (searchValues.file.includes(fileName) && searchValues.line === line && (column === undefined || searchValues.column === column))
continue;
return false;
}
@ -154,5 +155,6 @@ type SearchValues = {
status: 'passed' | 'failed' | 'flaky' | 'skipped';
file: string;
line: string;
column: string;
};

View File

@ -2064,6 +2064,36 @@ for (const useIntermediateMergeReport of [false, true] as const) {
await expect(page.getByText('passes title')).toBeVisible();
});
test('tests should filter by fileName:line/column', async ({ runInlineTest, showReport, page }) => {
const result = await runInlineTest({
'a.test.js': `
const { test, expect } = require('@playwright/test');
test('test1', async ({}) => { expect(1).toBe(1); });
test('test2', async ({}) => { expect(1).toBe(2); });
`,
}, { reporter: 'dot,html' }, { PW_TEST_HTML_REPORT_OPEN: 'never' });
expect(result.exitCode).toBe(1);
expect(result.passed).toBe(1);
expect(result.failed).toBe(1);
await showReport();
const searchInput = page.locator('.subnav-search-input');
await searchInput.fill('a.test.js:3:11');
await expect(page.getByText('a.test.js:3', { exact: true })).toBeVisible();
await expect(page.getByText('a.test.js:4', { exact: true })).toBeHidden();
await searchInput.fill('a.test.js:3');
await expect(page.getByText('a.test.js:3', { exact: true })).toBeVisible();
await expect(page.getByText('a.test.js:4', { exact: true })).toBeHidden();
await searchInput.fill('a.test.js:4:15');
await expect(page.getByText('a.test.js:3', { exact: true })).toBeHidden();
await expect(page.getByText('a.test.js:4', { exact: true })).toBeVisible();
});
test('should properly display beforeEach with and without title', async ({ runInlineTest, showReport, page }) => {
const result = await runInlineTest({
'a.test.js': `