Skip to content
Draft
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
11 changes: 7 additions & 4 deletions docs/report-format.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,18 @@ stored in [AWS Timestream], please see [Storage Schema].
"column": "<Positive integer, can be 0, optional>"
},
"browser": "<Can be 'chromium', 'chrome', 'firefox', 'webkit', 'safari' or 'edge', optional>",
"timeout": "<Positive integer representing milliseconds, can be 0, optional>",
"config": {
"timeout": "<Positive integer representing milliseconds, can be 0, optional>"
},
"started": "<Timestamp in UTC time>",
"duration": {
"total": "<Positive integer representing milliseconds, can be 0>",
"final": "<Positive integer representing milliseconds, can be 0>"
},
"tool": "<Non-empty string matching pattern '^(?!\\s).+(?<!\\s)$', optional>",
"experience": "<Non-empty string matching pattern '^(?!\\s).+(?<!\\s)$', optional>",
"type": "<Non-empty string matching pattern '^(?!\\s).+(?<!\\s)$', optional>",
"taxonomy": {
"tool": "<Non-empty string matching pattern '^(?!\\s).+(?<!\\s)$', optional>",
"type": "<Non-empty string matching pattern '^(?!\\s).+(?<!\\s)$', optional>"
},
"retries": "<Positive integer, can be 0>",
"github": {
"codeowners": "<Array of strings starting with '@', optional>"
Expand Down
31 changes: 20 additions & 11 deletions schemas/report/v3.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,22 +138,31 @@
"file"
]
},
"tool": {
"$ref": "#/$defs/nonEmptyUnpaddedString"
},
"experience": {
"$ref": "#/$defs/nonEmptyUnpaddedString"
},
"type": {
"$ref": "#/$defs/nonEmptyUnpaddedString"
"taxonomy": {
"type": "object",
"unevaluatedProperties": false,
"properties": {
"tool": {
"$ref": "#/$defs/nonEmptyUnpaddedString"
},
"type": {
"$ref": "#/$defs/nonEmptyUnpaddedString"
}
}
},
"started": {
"type": "string",
"format": "date-time"
},
"timeout": {
"type": "integer",
"minimum": 0
"config": {
"type": "object",
"unevaluatedProperties": false,
"properties": {
"timeout": {
"type": "integer",
"minimum": 0
}
}
},
"duration": {
"type": "object",
Expand Down
38 changes: 30 additions & 8 deletions src/helpers/report-builder.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ const reportMemberPriority = [
'browser',
'framework',
'operatingSystem',
'config',
'timeout',
'started',
'duration',
'total',
'final',
'taxonomy',
'tool',
'experience',
'type',
Expand Down Expand Up @@ -174,11 +176,12 @@ class ReportSummaryBuilder extends ReportBuilderBase {
}

class ReportDetailBuilder extends ReportBuilderBase {
constructor(reportConfiguration, codeowners) {
constructor(reportConfiguration, codeowners, { reportVersionLatest = false } = {}) {
super();

this._reportConfiguration = reportConfiguration;
this._codeowners = codeowners;
this._reportVersionLatest = reportVersionLatest;

this._setProperty('retries', 0);
}
Expand Down Expand Up @@ -206,9 +209,19 @@ class ReportDetailBuilder extends ReportBuilderBase {

const { type, tool, experience } = this._reportConfiguration.getTaxonomy(filePath);

this._setProperty('type', type, options);
this._setProperty('tool', tool, options);
this._setProperty('experience', experience, options);
if (this._reportVersionLatest) {
if (type != null) {
this._setNestedProperty('taxonomy', 'type', type, options);
}

if (tool != null) {
this._setNestedProperty('taxonomy', 'tool', tool, options);
}
} else {
this._setProperty('type', type, options);
this._setProperty('tool', tool, options);
this._setProperty('experience', experience, options);
}

if (this._codeowners) {
const owners = this._codeowners.getOwner(filePath);
Expand Down Expand Up @@ -286,7 +299,11 @@ class ReportDetailBuilder extends ReportBuilderBase {
}

setTimeout(timeout, options) {
this._setProperty('timeout', timeout, options);
if (this._reportVersionLatest) {
this._setNestedProperty('config', 'timeout', timeout, options);
} else {
this._setProperty('timeout', timeout, options);
}

return this;
}
Expand All @@ -308,6 +325,7 @@ class ReportBuilder extends ReportBuilderBase {

this._logger = logger;
this._verbose = verbose;
this._reportVersionLatest = reportVersionLatest;
this._reportConfiguration = new ReportConfiguration(reportConfigurationPath);

if (reportWriter) {
Expand Down Expand Up @@ -362,7 +380,9 @@ class ReportBuilder extends ReportBuilderBase {
const { details } = this._data;

if (!details.has(id)) {
details.set(id, new ReportDetailBuilder(this._reportConfiguration, this._codeowners));
details.set(id, new ReportDetailBuilder(this._reportConfiguration, this._codeowners, {
reportVersionLatest: this._reportVersionLatest
}));
}

return details.get(id);
Expand Down Expand Up @@ -390,8 +410,10 @@ class ReportBuilder extends ReportBuilderBase {
}

if (this._verbose) {
const { name, location, type, tool, experience } = detail;
const { name, location } = detail;
const prefix = `Test '${name}' at '${location}' is missing`;
const type = this._reportVersionLatest ? detail.taxonomy?.type : detail.type;
const tool = this._reportVersionLatest ? detail.taxonomy?.tool : detail.tool;

if (!type) {
this._logger.warning(`${prefix} a 'type'`);
Expand All @@ -401,7 +423,7 @@ class ReportBuilder extends ReportBuilderBase {
this._logger.warning(`${prefix} a 'tool'`);
}

if (!experience) {
if (!this._reportVersionLatest && !detail.experience) {
this._logger.warning(`${prefix} an 'experience'`);
}
}
Expand Down
60 changes: 20 additions & 40 deletions test/integration/data/validation/test-report-mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,91 +11,71 @@ export const testReportLatestPartial = {
name: 'reporter 1 > passed',
status: 'passed',
location: { file: 'test/integration/data/tests/mocha/reporter-1.test.js' },
timeout: 2000,
tool: 'Mocha 1 Test Reporting',
experience: 'Test Framework',
type: 'ui',
config: { timeout: 2000 },
taxonomy: { tool: 'Mocha 1 Test Reporting', type: 'ui' },
retries: 0
}, {
name: 'reporter 1 > skipped',
status: 'skipped',
location: { file: 'test/integration/data/tests/mocha/reporter-1.test.js' },
timeout: 2000,
tool: 'Mocha 1 Test Reporting',
experience: 'Test Framework',
type: 'ui',
config: { timeout: 2000 },
taxonomy: { tool: 'Mocha 1 Test Reporting', type: 'ui' },
retries: 0
}, {
name: 'reporter 1 > flaky',
status: 'passed',
location: { file: 'test/integration/data/tests/mocha/reporter-1.test.js' },
timeout: 2000,
tool: 'Mocha 1 Test Reporting',
experience: 'Test Framework',
type: 'ui',
config: { timeout: 2000 },
taxonomy: { tool: 'Mocha 1 Test Reporting', type: 'ui' },
retries: 2
}, {
name: 'reporter 1 > failed',
status: 'failed',
location: { file: 'test/integration/data/tests/mocha/reporter-1.test.js' },
timeout: 2000,
tool: 'Mocha 1 Test Reporting',
experience: 'Test Framework',
type: 'ui',
config: { timeout: 2000 },
taxonomy: { tool: 'Mocha 1 Test Reporting', type: 'ui' },
retries: 3
}, {
name: 'reporter 2 > passed',
status: 'passed',
location: { file: 'test/integration/data/tests/mocha/reporter-2.test.js' },
timeout: 2000,
tool: 'Test Reporting',
experience: 'Mocha 2 Test Framework',
type: 'integration',
config: { timeout: 2000 },
taxonomy: { tool: 'Test Reporting', type: 'integration' },
retries: 0
}, {
name: 'reporter 2 > skipped',
status: 'skipped',
location: { file: 'test/integration/data/tests/mocha/reporter-2.test.js' },
timeout: 2000,
tool: 'Test Reporting',
experience: 'Mocha 2 Test Framework',
type: 'integration',
config: { timeout: 2000 },
taxonomy: { tool: 'Test Reporting', type: 'integration' },
retries: 0
}, {
name: 'reporter 2 > flaky',
status: 'passed',
location: { file: 'test/integration/data/tests/mocha/reporter-2.test.js' },
timeout: 2000,
tool: 'Test Reporting',
experience: 'Mocha 2 Test Framework',
type: 'integration',
config: { timeout: 2000 },
taxonomy: { tool: 'Test Reporting', type: 'integration' },
retries: 2
}, {
name: 'reporter 2 > failed',
status: 'failed',
location: { file: 'test/integration/data/tests/mocha/reporter-2.test.js' },
timeout: 2000,
tool: 'Test Reporting',
experience: 'Mocha 2 Test Framework',
type: 'integration',
config: { timeout: 2000 },
taxonomy: { tool: 'Test Reporting', type: 'integration' },
retries: 3
}, {
name: 'reporter 1 > special/characters "(\\n\\r\\t\\b\\f)"',
status: 'passed',
location: { file: 'test/integration/data/tests/mocha/reporter-1.test.js' },
timeout: 2000,
tool: 'Mocha 1 Test Reporting',
experience: 'Test Framework',
type: 'ui',
config: { timeout: 2000 },
taxonomy: { tool: 'Mocha 1 Test Reporting', type: 'ui' },
retries: 0
}, {
name: 'reporter 2 > special/characters "(\\n\\r\\t\\b\\f)"',
status: 'passed',
location: { file: 'test/integration/data/tests/mocha/reporter-2.test.js' },
timeout: 2000,
tool: 'Test Reporting',
experience: 'Mocha 2 Test Framework',
type: 'integration',
config: { timeout: 2000 },
taxonomy: { tool: 'Test Reporting', type: 'integration' },
retries: 0
}]
};
Loading
Loading