feat(json-reporter): added parallelIndex to overrides-testReporter.d.ts and added initial test to reporter-json.spec.ts

Co-authored-by: Neel Deshmukh <neel.deshmukh1@gmail.com>
Co-authored-by: Marcelo Villalobos Diaz <mvillalobosdiaz@csumb.edu>
This commit is contained in:
Christopher Tangonan 2025-02-15 00:56:37 +00:00
parent 98faa5b0b6
commit b9efcc183b
2 changed files with 27 additions and 0 deletions

View file

@ -327,3 +327,29 @@ test.describe('report location', () => {
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('test 1 passes!', async ({}) => {
expect(1 + 1).toBe(2);
});
test('test 2 fails!', async ({}) => {
expect(1 + 1).toBe(3);
});
test('test 3 passes!', async ({}) => {
expect(1 + 1).toBe(2);
});
`
});
expect(result.passed).toBe(2);
expect(result.failed).toBe(1);
expect(result.results[0].workerIndex).toBe(0);
expect(result.results[0].parallelIndex).toBe(0);
expect(result.results[1].workerIndex).toBe(0);
expect(result.results[1].parallelIndex).toBe(0);
expect(result.results[2].workerIndex).toBe(1);
expect(result.results[2].parallelIndex).toBe(0);
});

View file

@ -109,6 +109,7 @@ export interface JSONReportError {
export interface JSONReportTestResult {
workerIndex: number;
parallelIndex: number;
status: TestStatus | undefined;
duration: number;
error: TestError | undefined;