improve test for git info in ui mode

This commit is contained in:
vitalets 2025-01-24 15:20:40 +04:00
parent 203951ec73
commit b311a38c85

View file

@ -14,22 +14,43 @@
* limitations under the License.
*/
import { test } from './ui-mode-fixtures';
import { test, expect } from './ui-mode-fixtures';
test('should display git info metadata', async ({ runUITest }) => {
const { page } = await runUITest({
const reporter = `
class Reporter {
onBegin(config, suite) {
console.log(JSON.stringify(config.metadata, null, 2));
}
printsToStdio() {
return true;
}
}
module.exports = Reporter;
`;
test('should render html report git info metadata', async ({ runUITest }) => {
const { page, testProcess } = await runUITest({
'reporter.ts': reporter,
'playwright.config.ts': `
import { defineConfig } from '@playwright/test';
export default defineConfig({
populateGitInfo: true,
reporter: './reporter.ts',
});
`,
'a.test.js': `
import { test, expect } from '@playwright/test';
test('should work', async ({}) => {});
`
}, {
BUILD_URL: 'https://playwright.dev',
});
await page.getByTitle('Run all').click();
// todo: what to check?
await page.getByTitle('Run all').click();
await expect(page.getByTestId('status-line')).toHaveText('1/1 passed (100%)');
// 1. testProcess.output is not populated with console.log from reporter
// 2. even with PWTEST_DEBUG=1 output contains unpopulated metadata: { actualWorkers: 1 }
expect(testProcess.output).toContain(`"ci.link": "https://playwright.dev"`);
});