Feedback use outputLines
This commit is contained in:
parent
32169b7950
commit
fd90424171
|
|
@ -31,6 +31,7 @@ export { countTimes } from '../config/commonFixtures';
|
|||
type CliRunResult = {
|
||||
exitCode: number,
|
||||
output: string,
|
||||
outputLines: string[],
|
||||
};
|
||||
|
||||
export type RunResult = {
|
||||
|
|
@ -330,7 +331,12 @@ export const test = base
|
|||
cwd,
|
||||
});
|
||||
const { exitCode } = await testProcess.exited;
|
||||
return { exitCode, output: testProcess.output.toString() };
|
||||
const output = testProcess.output.toString();
|
||||
return {
|
||||
exitCode,
|
||||
output,
|
||||
outputLines: parseOutputLines(output),
|
||||
};
|
||||
});
|
||||
},
|
||||
|
||||
|
|
@ -416,6 +422,10 @@ export function expectTestHelper(result: RunResult) {
|
|||
};
|
||||
}
|
||||
|
||||
function parseOutputLines(output: string): string[] {
|
||||
return output.split('\n').filter(line => line.startsWith('%%')).map(line => line.substring(2).trim());
|
||||
}
|
||||
|
||||
export function parseTestRunnerOutput(output: string) {
|
||||
const summary = (re: RegExp) => {
|
||||
let result = 0;
|
||||
|
|
@ -436,7 +446,7 @@ export function parseTestRunnerOutput(output: string) {
|
|||
const strippedOutput = stripAnsi(output);
|
||||
return {
|
||||
output: strippedOutput,
|
||||
outputLines: strippedOutput.split('\n').filter(line => line.startsWith('%%')).map(line => line.substring(2).trim()),
|
||||
outputLines: parseOutputLines(strippedOutput),
|
||||
rawOutput: output,
|
||||
passed,
|
||||
failed,
|
||||
|
|
|
|||
|
|
@ -32,18 +32,18 @@ const NEGATIVE_STATUS_MARK = DOES_NOT_SUPPORT_UTF8_IN_TERMINAL ? 'x ' : '✘ ';
|
|||
|
||||
const test = baseTest.extend<{
|
||||
showReport: (reportFolder?: string) => Promise<void>
|
||||
}>({
|
||||
showReport: async ({ page }, use) => {
|
||||
let server: HttpServer | undefined;
|
||||
await use(async (reportFolder?: string) => {
|
||||
reportFolder ??= test.info().outputPath('playwright-report');
|
||||
server = startHtmlReportServer(reportFolder) as HttpServer;
|
||||
await server.start();
|
||||
await page.goto(server.urlPrefix('precise'));
|
||||
});
|
||||
await server?.stop();
|
||||
}
|
||||
});
|
||||
}>({
|
||||
showReport: async ({ page }, use) => {
|
||||
let server: HttpServer | undefined;
|
||||
await use(async (reportFolder?: string) => {
|
||||
reportFolder ??= test.info().outputPath('playwright-report');
|
||||
server = startHtmlReportServer(reportFolder) as HttpServer;
|
||||
await server.start();
|
||||
await page.goto(server.urlPrefix('precise'));
|
||||
});
|
||||
await server?.stop();
|
||||
}
|
||||
});
|
||||
|
||||
test.use({ channel: 'chrome' });
|
||||
test.slow(!!process.env.CI);
|
||||
|
|
@ -1818,7 +1818,7 @@ test('merge reports must not change test ids when there is no need to', async ({
|
|||
'echo-test-id-reporter.js': `
|
||||
export default class EchoTestIdReporter {
|
||||
onTestBegin(test) {
|
||||
console.log('test.id:', test.id);
|
||||
console.log('%%' + test.id);
|
||||
}
|
||||
};
|
||||
`,
|
||||
|
|
@ -1859,28 +1859,27 @@ test('merge reports must not change test ids when there is no need to', async ({
|
|||
let testIdsFromShard1: string[];
|
||||
let testIdsFromShard2: string[];
|
||||
let testIdsFromMergedReport: string[];
|
||||
const parseTestIdsFromOutput = (output: string) => output.split('\n').filter(s => s.startsWith('test.id:')).map(s => s.split('test.id:')[1].trim()).sort();
|
||||
{
|
||||
const { exitCode, output } = await runInlineTest(files, { workers: 1 }, undefined, { additionalArgs: ['--config', test.info().outputPath('single-run.config.ts')] });
|
||||
const { exitCode, outputLines } = await runInlineTest(files, { workers: 1 }, undefined, { additionalArgs: ['--config', test.info().outputPath('single-run.config.ts')] });
|
||||
expect(exitCode).toBe(0);
|
||||
testIdsFromSingleRun = parseTestIdsFromOutput(output);
|
||||
testIdsFromSingleRun = outputLines.sort();
|
||||
expect(testIdsFromSingleRun.length).toEqual(3);
|
||||
}
|
||||
{
|
||||
const { exitCode, output } = await runInlineTest(files, { workers: 1 }, {}, { additionalArgs: ['--config', test.info().outputPath('shard-1.config.ts')] });
|
||||
const { exitCode, outputLines } = await runInlineTest(files, { workers: 1 }, {}, { additionalArgs: ['--config', test.info().outputPath('shard-1.config.ts')] });
|
||||
expect(exitCode).toBe(0);
|
||||
testIdsFromShard1 = parseTestIdsFromOutput(output);
|
||||
testIdsFromShard1 = outputLines.sort();
|
||||
}
|
||||
{
|
||||
const { exitCode, output } = await runInlineTest(files, { workers: 1 }, { PWTEST_BLOB_DO_NOT_REMOVE: '1' }, { additionalArgs: ['--config', test.info().outputPath('shard-2.config.ts')] });
|
||||
const { exitCode, outputLines } = await runInlineTest(files, { workers: 1 }, { PWTEST_BLOB_DO_NOT_REMOVE: '1' }, { additionalArgs: ['--config', test.info().outputPath('shard-2.config.ts')] });
|
||||
expect(exitCode).toBe(0);
|
||||
testIdsFromShard2 = parseTestIdsFromOutput(output);
|
||||
testIdsFromShard2 = outputLines.sort();
|
||||
expect([...testIdsFromShard1, ...testIdsFromShard2].sort()).toEqual(testIdsFromSingleRun);
|
||||
}
|
||||
{
|
||||
const { exitCode, output } = await mergeReports(test.info().outputPath('blob-report'), undefined, { additionalArgs: ['--config', test.info().outputPath('merge.config.ts')] });
|
||||
const { exitCode, outputLines } = await mergeReports(test.info().outputPath('blob-report'), undefined, { additionalArgs: ['--config', test.info().outputPath('merge.config.ts')] });
|
||||
expect(exitCode).toBe(0);
|
||||
testIdsFromMergedReport = parseTestIdsFromOutput(output);
|
||||
testIdsFromMergedReport = outputLines.sort();
|
||||
expect(testIdsFromMergedReport).toEqual(testIdsFromSingleRun);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue