chore: added starting time of test to the base json reporter (#16885)

This commit is contained in:
nate-ro 2022-08-30 20:03:21 -07:00 committed by GitHub
parent f30ac1d678
commit 409bab59ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 0 deletions

View File

@ -177,6 +177,7 @@ class JSONReporter implements Reporter {
stderr: result.stderr.map(s => stdioEntry(s)),
retry: result.retry,
steps: steps.length ? steps.map(s => this._serializeTestStep(s)) : undefined,
startTime: result.startTime,
attachments: result.attachments.map(a => ({
name: a.name,
contentType: a.contentType,

View File

@ -493,6 +493,7 @@ export interface JSONReportTestResult {
stderr: JSONReportSTDIOEntry[];
retry: number;
steps?: JSONReportTestStep[];
startTime: Date;
attachments: {
name: string;
path?: string;

View File

@ -235,3 +235,16 @@ test('should add line in addition to file json without CI', async ({ runInlineTe
expect(stripAnsi(result.output)).toContain('[1/1] a.test.js:6:7 one');
expect(fs.existsSync(testInfo.outputPath('a.json'))).toBeTruthy();
});
test('should have starting time in results', async ({ runInlineTest }, testInfo) => {
const result = await runInlineTest({
'a.test.js': `
const { test } = pwt;
test('math works!', async ({}) => {
expect(1 + 1).toBe(2);
});
`
}, { reporter: 'json' });
expect(result.exitCode).toBe(0);
const startTime = result.report.suites[0].specs[0].tests[0].results[0].startTime;
expect(new Date(startTime).getTime()).toBeGreaterThan(new Date('1/1/2000').getTime());
});

View File

@ -104,6 +104,7 @@ export interface JSONReportTestResult {
stderr: JSONReportSTDIOEntry[];
retry: number;
steps?: JSONReportTestStep[];
startTime: Date;
attachments: {
name: string;
path?: string;