fix(blob): use reporters from the merge config (#27301)

Fixes https://github.com/microsoft/playwright/issues/27281
This commit is contained in:
Yury Semikhatsky 2023-09-26 11:41:17 -07:00 committed by GitHub
parent 07e794eb83
commit d198784f1a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 1 deletions

View file

@ -32,7 +32,7 @@ export type JsonConfig = Pick<FullConfig, 'configFile' | 'globalTimeout' | 'maxF
listOnly: boolean;
};
export type MergeReporterConfig = Pick<FullConfig, 'configFile' | 'quiet' | 'reportSlowTests' | 'rootDir' >;
export type MergeReporterConfig = Pick<FullConfig, 'configFile' | 'quiet' | 'reportSlowTests' | 'rootDir' | 'reporter' >;
export type JsonPattern = {
s?: string;
@ -327,6 +327,7 @@ export class TeleReporterReceiver {
result.rootDir = this._reportConfig.rootDir;
result.reportSlowTests = this._reportConfig.reportSlowTests;
result.quiet = this._reportConfig.quiet;
result.reporter = [...this._reportConfig.reporter];
}
return result;
}

View file

@ -1377,3 +1377,42 @@ function readAllFromStreamAsString(stream: NodeJS.ReadableStream): Promise<strin
stream.on('end', () => resolve(Buffer.concat(chunks).toString('utf8')));
});
}
test('reporter list in the custom config', async ({ runInlineTest, mergeReports }) => {
test.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/27281' });
const reportDir = test.info().outputPath('blob-report');
const files = {
'playwright.config.ts': `
module.exports = { reporter: 'blob' };
`,
'a.test.ts': `
import { test, expect } from '@playwright/test';
test('first', async ({}) => {
});
`,
'merged/testReporter.js': `
class TestReporter {
onBegin(fullConfig, suite) {
console.log('reporter', fullConfig.reporter);
}
}
module.exports = TestReporter;
`,
'merged/playwright.config.ts': `
module.exports = {
retries: 1,
reporter: [['./testReporter.js', { myOpt: 1 }]]
};
`,
};
await runInlineTest(files);
const { exitCode, output } = await mergeReports(reportDir, undefined, { additionalArgs: ['--config', test.info().outputPath('merged/playwright.config.ts')] });
expect(exitCode).toBe(0);
const text = stripAnsi(output);
expect(text).toContain('testReporter.js');
expect(text).toContain('{ myOpt: 1 }');
});