feat(json-reporter): added parallelIndex to TestResult (#34740)
This commit is contained in:
parent
4a79c214f0
commit
c22c10f7d8
|
@ -203,6 +203,7 @@ class JSONReporter implements ReporterV2 {
|
||||||
const steps = result.steps.filter(s => s.category === 'test.step');
|
const steps = result.steps.filter(s => s.category === 'test.step');
|
||||||
const jsonResult: JSONReportTestResult = {
|
const jsonResult: JSONReportTestResult = {
|
||||||
workerIndex: result.workerIndex,
|
workerIndex: result.workerIndex,
|
||||||
|
parallelIndex: result.parallelIndex,
|
||||||
status: result.status,
|
status: result.status,
|
||||||
duration: result.duration,
|
duration: result.duration,
|
||||||
error: result.error,
|
error: result.error,
|
||||||
|
|
|
@ -291,6 +291,7 @@ export interface JSONReportError {
|
||||||
|
|
||||||
export interface JSONReportTestResult {
|
export interface JSONReportTestResult {
|
||||||
workerIndex: number;
|
workerIndex: number;
|
||||||
|
parallelIndex: number;
|
||||||
status: TestStatus | undefined;
|
status: TestStatus | undefined;
|
||||||
duration: number;
|
duration: number;
|
||||||
error: TestError | undefined;
|
error: TestError | undefined;
|
||||||
|
|
|
@ -327,3 +327,31 @@ test.describe('report location', () => {
|
||||||
expect(fs.existsSync(testInfo.outputPath('foo', 'bar', 'baz', 'my-report.json'))).toBe(true);
|
expect(fs.existsSync(testInfo.outputPath('foo', 'bar', 'baz', 'my-report.json'))).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should report parallelIndex', async ({ runInlineTest }, testInfo) => {
|
||||||
|
const result = await runInlineTest({
|
||||||
|
'tests/a.spec.js': `
|
||||||
|
import { test, expect } from '@playwright/test';
|
||||||
|
const fs = require('fs');
|
||||||
|
test.describe.configure({ mode: 'parallel' });
|
||||||
|
test('test 1 passes!', async ({}) => {
|
||||||
|
await new Promise(f => setTimeout(f, 1000));
|
||||||
|
});
|
||||||
|
test('test 2 fails!', async ({}) => {
|
||||||
|
expect(1 + 1).toBe(3);
|
||||||
|
await new Promise(f => setTimeout(f, 1000));
|
||||||
|
});
|
||||||
|
test('test 3 passes!', async ({}) => {
|
||||||
|
await new Promise(f => setTimeout(f, 1000));
|
||||||
|
});
|
||||||
|
`
|
||||||
|
}, { 'workers': '2', 'reporter': 'json' });
|
||||||
|
expect(result.passed).toBe(2);
|
||||||
|
expect(result.failed).toBe(1);
|
||||||
|
expect(result.report.suites[0].specs[0].tests[0].results[0].workerIndex).toBe(0);
|
||||||
|
expect(result.report.suites[0].specs[1].tests[0].results[0].workerIndex).toBe(1);
|
||||||
|
expect(result.report.suites[0].specs[2].tests[0].results[0].workerIndex).toBe(2);
|
||||||
|
expect(result.report.suites[0].specs[0].tests[0].results[0].parallelIndex).toBe(0);
|
||||||
|
expect(result.report.suites[0].specs[1].tests[0].results[0].parallelIndex).toBe(1);
|
||||||
|
expect(result.report.suites[0].specs[2].tests[0].results[0].parallelIndex).toBe(1);
|
||||||
|
});
|
||||||
|
|
|
@ -109,6 +109,7 @@ export interface JSONReportError {
|
||||||
|
|
||||||
export interface JSONReportTestResult {
|
export interface JSONReportTestResult {
|
||||||
workerIndex: number;
|
workerIndex: number;
|
||||||
|
parallelIndex: number;
|
||||||
status: TestStatus | undefined;
|
status: TestStatus | undefined;
|
||||||
duration: number;
|
duration: number;
|
||||||
error: TestError | undefined;
|
error: TestError | undefined;
|
||||||
|
|
Loading…
Reference in New Issue