Skip to content

Commit

Permalink
test: use intermediate merge report for JSON repoter (#27092)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxschmitt authored Sep 15, 2023
1 parent 699e790 commit 26cbe69
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tests/playwright-test/playwright-test-fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export async function writeFiles(testInfo: TestInfo, files: Files, initial: bool
export const cliEntrypoint = path.join(__dirname, '../../packages/playwright-test/cli.js');

const configFile = (baseDir: string, files: Files): string | undefined => {
for (const [name, content] of Object.entries(files)) {
for (const [name, content] of Object.entries(files)) {
if (name.includes('playwright.config')) {
if (content.includes('reporter:') || content.includes('reportSlowTests:'))
return path.resolve(baseDir, name);
Expand Down Expand Up @@ -128,11 +128,13 @@ async function runPlaywrightTest(childProcess: CommonFixtures['childProcess'], b
params.reporter = 'blob';
}
const reportFile = path.join(baseDir, 'report.json');
const testProcess = startPlaywrightTest(childProcess, baseDir, params, {
// When we have useIntermediateMergeReport, we want the JSON reporter only at the merge step.
const envWithJsonReporter = {
PW_TEST_REPORTER: path.join(__dirname, '../../packages/playwright/lib/reporters/json.js'),
PLAYWRIGHT_JSON_OUTPUT_NAME: reportFile,
...env,
}, options);
};
const testProcess = startPlaywrightTest(childProcess, baseDir, params, useIntermediateMergeReport ? env : envWithJsonReporter, options);
const { exitCode } = await testProcess.exited;
let output = testProcess.output.toString();

Expand All @@ -146,7 +148,7 @@ async function runPlaywrightTest(childProcess: CommonFixtures['childProcess'], b
const cwd = options.cwd ? path.resolve(baseDir, options.cwd) : baseDir;
const packageRoot = path.resolve(baseDir, findPackageJSONDir(files, options.cwd ?? ''));
const relativeBlobReportPath = path.relative(cwd, path.join(packageRoot, 'blob-report'));
const mergeResult = await mergeReports(relativeBlobReportPath, env, { cwd, additionalArgs });
const mergeResult = await mergeReports(relativeBlobReportPath, envWithJsonReporter, { cwd, additionalArgs });
expect(mergeResult.exitCode).toBe(0);
output = mergeResult.output;
}
Expand Down

0 comments on commit 26cbe69

Please sign in to comment.