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
2 changes: 1 addition & 1 deletion packages/playwright/src/reporters/json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class JSONReporter implements ReporterV2 {
}

for (const spec of from.specs || []) {
const toSpec = to.specs.find(s => s.title === spec.title && s.file === toPosixPath(path.relative(this.config.rootDir, spec.file)) && s.line === spec.line && s.column === spec.column);
const toSpec = to.specs.find(s => s.title === spec.title && this._locationMatches(s, spec));
if (toSpec)
toSpec.tests.push(...spec.tests);
else
Expand Down
29 changes: 29 additions & 0 deletions tests/playwright-test/reporter-json.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,35 @@ test('should report projects and stats', async ({ runInlineTest }, testInfo) =>
expect(result.report.stats.duration).toEqual(expect.any(Number));
});

test('should merge specs from all projects when testDir is not cwd', async ({ runInlineTest }) => {
const result = await runInlineTest({
'playwright.config.ts': `
module.exports = {
testDir: 'tests',
projects: [{ name: 'p1' }, { name: 'p2' }],
};
`,
'tests/a.test.js': `
import { test, expect } from '@playwright/test';
test('math works!', async ({}) => {
expect(1 + 1).toBe(2);
});
test.describe('suite', () => {
test('nested math works!', async ({}) => {
expect(1 + 1).toBe(2);
});
});
`
});
expect(result.exitCode).toBe(0);
const fileSuite = result.report.suites[0];
expect(fileSuite.specs.length).toBe(1);
expect(fileSuite.specs[0].tests.map(t => t.projectName)).toEqual(['p1', 'p2']);
expect(fileSuite.suites!.length).toBe(1);
expect(fileSuite.suites![0].specs.length).toBe(1);
expect(fileSuite.suites![0].specs[0].tests.map(t => t.projectName)).toEqual(['p1', 'p2']);
});

test('should show steps', async ({ runInlineTest }) => {
const result = await runInlineTest({
'a.test.js': `
Expand Down