Skip to content

Commit

Permalink
feat: output more location and timeout information (#209)
Browse files Browse the repository at this point in the history
  • Loading branch information
devpow112 authored May 2, 2024
1 parent 8a938eb commit 7be98be
Show file tree
Hide file tree
Showing 8 changed files with 217 additions and 40 deletions.
7 changes: 7 additions & 0 deletions src/helpers/report-builder.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const reportMemberPriority = [
'browser',
'framework',
'operatingSystem',
'timeout',
'started',
'duration',
'total',
Expand Down Expand Up @@ -267,6 +268,12 @@ class ReportDetailBuilder extends ReportBuilderBase {

return this;
}

setTimeout(timeout, options) {
this._setProperty('timeout', timeout, options);

return this;
}
}

class ReportBuilder extends ReportBuilderBase {
Expand Down
5 changes: 3 additions & 2 deletions src/reporters/mocha.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class TestReportingMochaReporter extends Spec {
}

_onTestBegin(test) {
const { file } = test;
const { file, _timeout } = test;

if (this._report.ignoreFilePath(file)) {
return;
Expand All @@ -70,7 +70,8 @@ class TestReportingMochaReporter extends Spec {
detail
.setName(name)
.setLocationFile(file)
.setStarted((new Date()).toISOString());
.setStarted((new Date()).toISOString())
.setTimeout(_timeout); // using internal property, not ideal
}

_onTestRetry(test) {
Expand Down
5 changes: 4 additions & 1 deletion src/reporters/playwright.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default class Reporter {
}

onTestEnd(test, result) {
const { location: { file } } = test;
const { timeout, location: { file, line, column } } = test;

if (this._report.ignoreFilePath(file)) {
return;
Expand All @@ -77,7 +77,10 @@ export default class Reporter {
.getDetail(id)
.setName(name)
.setLocationFile(file)
.setLocationLine(line)
.setLocationColumn(column)
.setStarted(startTime)
.setTimeout(Math.round(timeout))
.addDuration(Math.round(duration));

if (retry !== 0) {
Expand Down
4 changes: 3 additions & 1 deletion src/reporters/web-test-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export function reporter(options = {}) {
}

const browser = browserName.toLowerCase();
const { testsFinishTimeout } = testConfig;

for (const test of tests) {
const { skipped, passed, duration, name } = test;
Expand All @@ -48,7 +49,8 @@ export function reporter(options = {}) {
.setName(testName)
.setLocationFile(testFile)
.setStarted(started)
.setBrowser(browser);
.setBrowser(browser)
.setTimeout(testsFinishTimeout);

if (passed) {
detail.setPassed();
Expand Down
15 changes: 14 additions & 1 deletion test/integration/data/validation/test-report-mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,18 @@ export const testReportV2Partial = {
summary: {
status: 'failed',
framework: 'mocha',
count: { passed: 2, failed: 2, skipped: 2, flaky: 2 }
count: {
passed: 2,
failed: 2,
skipped: 2,
flaky: 2
}
},
details: [{
name: 'reporter tests 1 > test',
status: 'passed',
location: { file: 'test/integration/data/mocha-1.test.js' },
timeout: 2000,
tool: 'Mocha 1 Test Reporting',
experience: 'Test Framework',
type: 'ui',
Expand All @@ -93,6 +99,7 @@ export const testReportV2Partial = {
name: 'reporter tests 1 > skipped test',
status: 'skipped',
location: { file: 'test/integration/data/mocha-1.test.js' },
timeout: 2000,
tool: 'Mocha 1 Test Reporting',
experience: 'Test Framework',
type: 'ui',
Expand All @@ -101,6 +108,7 @@ export const testReportV2Partial = {
name: 'reporter tests 1 > flaky test',
status: 'passed',
location: { file: 'test/integration/data/mocha-1.test.js' },
timeout: 2000,
tool: 'Mocha 1 Test Reporting',
experience: 'Test Framework',
type: 'ui',
Expand All @@ -109,6 +117,7 @@ export const testReportV2Partial = {
name: 'reporter tests 1 > failed test',
status: 'failed',
location: { file: 'test/integration/data/mocha-1.test.js' },
timeout: 2000,
tool: 'Mocha 1 Test Reporting',
experience: 'Test Framework',
type: 'ui',
Expand All @@ -117,6 +126,7 @@ export const testReportV2Partial = {
name: 'reporter tests 2 > test',
status: 'passed',
location: { file: 'test/integration/data/mocha-2.test.js' },
timeout: 2000,
tool: 'Test Reporting',
experience: 'Mocha 2 Test Framework',
type: 'integration',
Expand All @@ -125,6 +135,7 @@ export const testReportV2Partial = {
name: 'reporter tests 2 > skipped test',
status: 'skipped',
location: { file: 'test/integration/data/mocha-2.test.js' },
timeout: 2000,
tool: 'Test Reporting',
experience: 'Mocha 2 Test Framework',
type: 'integration',
Expand All @@ -133,6 +144,7 @@ export const testReportV2Partial = {
name: 'reporter tests 2 > flaky test',
status: 'passed',
location: { file: 'test/integration/data/mocha-2.test.js' },
timeout: 2000,
tool: 'Test Reporting',
experience: 'Mocha 2 Test Framework',
type: 'integration',
Expand All @@ -141,6 +153,7 @@ export const testReportV2Partial = {
name: 'reporter tests 2 > failed test',
status: 'failed',
location: { file: 'test/integration/data/mocha-2.test.js' },
timeout: 2000,
tool: 'Test Reporting',
experience: 'Mocha 2 Test Framework',
type: 'integration',
Expand Down
Loading

0 comments on commit 7be98be

Please sign in to comment.