Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion packages/playwright/src/isomorphic/teleReceiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,19 @@ export class TeleReporterReceiver {
projectSuite = new TeleSuite(project.name, 'project');
this._rootSuite._addSuite(projectSuite);
}

const parsed = this._parseProject(project);
// Always update project in watch mode.
projectSuite._project = this._parseProject(project);
projectSuite._project = parsed;

let index = -1;
if (this._options.mergeProjects)
index = this._config.projects.findIndex(p => p.name === project.name);
if (index === -1)
this._config.projects.push(parsed);
else
this._config.projects[index] = parsed;

for (const suite of project.suites)
this._mergeSuiteInto(suite, projectSuite);
}
Expand Down
39 changes: 39 additions & 0 deletions tests/playwright-test/reporter-blob.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2287,3 +2287,42 @@ test('shard chart', async ({ runInlineTest, writeFiles, showReport, page, mergeR
- listitem /@mac/
`);
});

test('should populate projects in config when merging reports', async ({ runInlineTest, mergeReports }) => {
const reportDir = test.info().outputPath('blob-report');
class CustomReporter {
onBegin(config, suite) {
const projectNames = config.projects.map(p => p.name);
console.log('%%' + JSON.stringify(projectNames));
}
}
const files = {
'reporter.js': `module.exports = ${CustomReporter.toString()};`,
'playwright.config.ts': `
module.exports = {
reporter: [['blob', { outputDir: '${reportDir.replace(/\\/g, '/')}' }]],
projects: [
{ name: 'setup' },
{ name: 'p1', dependencies: ['setup'] },
{ name: 'p2', dependencies: ['setup'] },
]
};
`,
'a.test.js': `
import { test } from '@playwright/test';
test('test 1', async ({}) => {});
`,
};

await runInlineTest(files, { shard: `1/2`, workers: 1 });
await runInlineTest(files, { shard: `2/2`, workers: 1 }, { PWTEST_BLOB_DO_NOT_REMOVE: '1' });

const reportFiles = await fs.promises.readdir(reportDir);
expect(reportFiles).toHaveLength(2);

const { exitCode, outputLines } = await mergeReports(reportDir, {}, { additionalArgs: ['--reporter', test.info().outputPath('reporter.js')] });
expect(exitCode).toBe(0);

const projectNames = JSON.parse(outputLines[0]);
expect(projectNames).toEqual(['setup', 'p1', 'setup', 'p2']);
});
Loading