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
12 changes: 12 additions & 0 deletions docs/report-builder.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ const report = new ReportBuilder('your-framework-name', logger);
* `reportConfigurationPath` (default: `./d2l-test-reporting.config.json`): Path
to the D2L test reporting configuration file for taxonomy mapping and ignore
patterns. See [Report Configuration Format] for the schema.
* `reportVersion` (default: `3`): Report schema version to generate. Version 4
is an opt-in schema that supports an optional detail `testId`.
* `verbose` (default: `false`): Enable verbose logging for debugging purposes.

## How It Works
Expand Down Expand Up @@ -137,6 +139,16 @@ const testId = `${test.file}[${test.fullName}]`;
// Example: "test/unit/component.test.js[MyComponent > should render]"
```

For version 4 reports, set a stable logical identity on the detail. This lets
otherwise identical details remain distinct in the report. `setTestId()` is
only available when `reportVersion` is `4`.

```js
if (report.getVersion() === 4) {
report.getDetail(testId).setTestId(testId);
}
```

### Checking Ignored Files

Always check before processing a test:
Expand Down
338 changes: 338 additions & 0 deletions schemas/report/v4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,338 @@
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
"$id": "/test-reporting/schemas/report/v4.json",
"type": "object",
"unevaluatedProperties": false,
"properties": {
"id": {
"type": "string",
"format": "uuid"
},
"version": {
"type": "integer",
"const": 4
},
"summary": {
"$ref": "#/$defs/context",
"type": "object",
"unevaluatedProperties": false,
"properties": {
"framework": {
"$ref": "#/$defs/nonEmptyUnpaddedString"
},
"lms": {
"type": "object",
"unevaluatedProperties": false,
"properties": {
"buildNumber": {
"type": "string",
"pattern": "^([0-9]{2}\\.){2}[0-9]{1,2}\\.[0-9]{5}$",
"errorMessage": {
"pattern": "should be a valid LMS build number (XX.XX.XX.XXXXX)"
}
},
"instanceUrl": {
"type": "string",
"format": "uri"
}
}
},
"operatingSystem": {
"type": "string",
"enum": [
"windows",
"linux",
"mac"
]
},
"started": {
"type": "string",
"format": "date-time"
},
"duration": {
"type": "object",
"unevaluatedProperties": false,
"properties": {
"total": {
"type": "integer",
"minimum": 0
}
},
"required": [
"total"
]
},
"status": {
"type": "string",
"enum": [
"passed",
"failed"
]
},
"count": {
"type": "object",
"unevaluatedProperties": false,
"properties": {
"passed": {
"type": "integer",
"minimum": 0
},
"failed": {
"type": "integer",
"minimum": 0
},
"skipped": {
"type": "integer",
"minimum": 0
},
"flaky": {
"type": "integer",
"minimum": 0
}
},
"required": [
"passed",
"failed",
"skipped",
"flaky"
]
}
},
"required": [
"operatingSystem",
"framework",
"started",
"duration",
"status",
"count"
]
},
"details": {
"type": "array",
"minItems": 1,
"uniqueItems": true,
"items": {
"type": "object",
"unevaluatedProperties": false,
"properties": {
"testId": {
"$ref": "#/$defs/nonEmptyUnpaddedString"
},
"name": {
"$ref": "#/$defs/nonEmptyUnpaddedString"
},
"location": {
"type": "object",
"unevaluatedProperties": false,
"properties": {
"file": {
"$ref": "#/$defs/nonEmptyUnpaddedString"
},
"line": {
"type": "integer",
"minimum": 0
},
"column": {
"type": "integer",
"minimum": 0
}
}
},
"taxonomy": {
"type": "object",
"unevaluatedProperties": false,
"properties": {
"tool": {
"$ref": "#/$defs/nonEmptyUnpaddedString"
},
"type": {
"$ref": "#/$defs/nonEmptyUnpaddedString"
}
}
},
"started": {
"type": "string",
"format": "date-time"
},
"configuration": {
"type": "object",
"unevaluatedProperties": false,
"properties": {
"timeout": {
"type": "integer",
"minimum": 0
}
}
},
"duration": {
"type": "object",
"unevaluatedProperties": false,
"properties": {
"final": {
"type": "integer",
"minimum": 0
},
"total": {
"type": "integer",
"minimum": 0
}
},
"required": [
"final",
"total"
]
},
"status": {
"type": "string",
"enum": [
"passed",
"failed",
"skipped"
]
},
"browser": {
"type": "string",
"enum": [
"chromium",
"chrome",
"firefox",
"webkit",
"safari",
"edge"
]
},
"retries": {
"type": "integer",
"minimum": 0
},
"github": {
"type": "object",
"unevaluatedProperties": false,
"properties": {
"codeowners": {
"type": "array",
"items": {
"$ref": "#/$defs/githubCodeownerString"
},
"minItems": 1
}
}
}
},
"required": [
"name",
"started",
"duration",
"status",
"retries"
]
}
}
},
"required": [
"id",
"version",
"summary",
"details"
],
"$defs": {
"nonEmptyUnpaddedString": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"$id": "/test-reporting/schemas/report/v4/non-empty-unpadded-string.json",
"type": "string",
"pattern": "^(?!\\s).+(?<!\\s)$",
"minLength": 1,
"errorMessage": {
"pattern": "should be non-empty without leading or trailing whitespace"
}
},
"githubCodeownerString": {
"allOf": [
{
"$ref": "#/$defs/nonEmptyUnpaddedString"
},
{
"type": "string",
"pattern": "^@\\S+$",
"minLength": 2,
"errorMessage": {
"pattern": "should be a valid codeowner starting with @ and containing no whitespace"
}
}
]
},
"context": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"$id": "/test-reporting/schemas/report/v4/context.json",
"type": "object",
"properties": {
"github": {
"type": "object",
"unevaluatedProperties": false,
"properties": {
"organization": {
"$ref": "#/$defs/gitHubAllowedCharactersString"
},
"repository": {
"$ref": "#/$defs/gitHubAllowedCharactersString"
},
"workflow": {
"$ref": "/test-reporting/schemas/report/v4/non-empty-unpadded-string.json"
},
"runId": {
"type": "integer",
"minimum": 0
},
"runAttempt": {
"type": "integer",
"minimum": 1
}
},
"required": [
"organization",
"repository",
"workflow",
"runId",
"runAttempt"
]
},
"git": {
"type": "object",
"unevaluatedProperties": false,
"properties": {
"branch": {
"$ref": "/test-reporting/schemas/report/v4/non-empty-unpadded-string.json"
},
"sha": {
"type": "string",
"minLength": 40,
"maxLength": 40,
"pattern": "^[A-Fa-f0-9]+$",
"errorMessage": {
"pattern": "should be a git hash"
}
}
},
"required": [
"branch",
"sha"
]
}
},
"required": [
"github",
"git"
],
"$defs": {
"gitHubAllowedCharactersString": {
"type": "string",
"minLength": 1,
"pattern": "^[A-Za-z0-9_.-]+$",
"errorMessage": {
"pattern": "should be a valid github string, must include only alpha numeric, ., _, or - characters"
}
}
}
}
}
}
Loading