Skip to content

Commit 616b2b8

Browse files
committed
feat: add env properties
1 parent 7f7d9ca commit 616b2b8

File tree

4 files changed

+37
-1
lines changed

4 files changed

+37
-1
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ reporter: [
122122
osVersion: '5.4.0', // Optional: Specify the OS version.
123123
buildName: 'MyApp Build', // Optional: Specify the build name.
124124
buildNumber: '100', // Optional: Specify the build number.
125+
buildUrl: "https://ctrf.io", // Optional: Specify the build url.
126+
repositoryName: "ctrf-json", // Optional: Specify the repository name.
127+
repositoryUrl: "https://gh.io", // Optional: Specify the repository url.
128+
branchName: "main", // Optional: Specify the branch name.
129+
testEnvironment: "staging" // Optional: Specify the test environment (e.g. staging, production).
125130
}]
126131
],
127132
```

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jest-ctrf-json-reporter",
3-
"version": "0.0.7",
3+
"version": "0.0.8",
44
"description": "A Jest test reporter to create test results reports",
55
"main": "dist/index.js",
66
"scripts": {

src/generate-report.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ interface ReporterConfigOptions {
2828
osVersion?: string | undefined
2929
buildName?: string | undefined
3030
buildNumber?: string | undefined
31+
buildUrl?: string | undefined
32+
repositoryName?: string | undefined
33+
repositoryUrl?: string | undefined
34+
branchName?: string | undefined
35+
testEnvironment?: string | undefined
3136
}
3237

3338
class GenerateCtrfReport implements Reporter {
@@ -57,6 +62,11 @@ class GenerateCtrfReport implements Reporter {
5762
osVersion: reporterOptions?.osVersion ?? undefined,
5863
buildName: reporterOptions?.buildName ?? undefined,
5964
buildNumber: reporterOptions?.buildNumber ?? undefined,
65+
buildUrl: reporterOptions?.buildUrl ?? undefined,
66+
repositoryName: reporterOptions?.repositoryName ?? undefined,
67+
repositoryUrl: reporterOptions?.repositoryUrl ?? undefined,
68+
branchName: reporterOptions?.branchName ?? undefined,
69+
testEnvironment: reporterOptions?.testEnvironment ?? undefined,
6070
}
6171

6272
this.ctrfReport = {
@@ -229,6 +239,22 @@ class GenerateCtrfReport implements Reporter {
229239
if (reporterConfigOptions.buildNumber !== undefined) {
230240
this.ctrfEnvironment.buildNumber = reporterConfigOptions.buildNumber
231241
}
242+
if (reporterConfigOptions.buildUrl !== undefined) {
243+
this.ctrfEnvironment.buildUrl = reporterConfigOptions.buildUrl
244+
}
245+
if (reporterConfigOptions.repositoryName !== undefined) {
246+
this.ctrfEnvironment.repositoryName = reporterConfigOptions.repositoryName
247+
}
248+
if (reporterConfigOptions.repositoryUrl !== undefined) {
249+
this.ctrfEnvironment.repositoryUrl = reporterConfigOptions.repositoryUrl
250+
}
251+
if (reporterConfigOptions.branchName !== undefined) {
252+
this.ctrfEnvironment.branchName = reporterConfigOptions.branchName
253+
}
254+
if (reporterConfigOptions.testEnvironment !== undefined) {
255+
this.ctrfEnvironment.testEnvironment =
256+
reporterConfigOptions.testEnvironment
257+
}
232258
}
233259

234260
hasEnvironmentDetails(environment: CtrfEnvironment): boolean {

types/ctrf.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ export interface CtrfEnvironment {
5555
osVersion?: string
5656
buildName?: string
5757
buildNumber?: string
58+
buildUrl?: string
59+
repositoryName?: string
60+
repositoryUrl?: string
61+
branchName?: string
62+
testEnvironment?: string
5863
extra?: Record<string, any>
5964
}
6065

0 commit comments

Comments
 (0)