Skip to content

Commit

Permalink
feat: add additional env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
Ma11hewThomas committed Jun 5, 2024
1 parent 7eafa22 commit 2e03bce
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ reporter: [
osVersion: '5.4.0', // Optional: Specify the OS version.
buildName: 'MyApp Build', // Optional: Specify the build name.
buildNumber: '100', // Optional: Specify the build number.
buildUrl: "https://ctrf.io", // Optional: Specify the build url.
repositoryName: "ctrf-json", // Optional: Specify the repository name.
repositoryUrl: "https://gh.io", // Optional: Specify the repository url.
branchName: "main", // Optional: Specify the branch name.
testEnvironment: "staging" // Optional: Specify the test environment (e.g. staging, production).
}]
],
```
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "playwright-ctrf-json-reporter",
"version": "0.0.12",
"version": "0.0.13",
"description": "A Playwright JSON test reporter to create test results reports",
"main": "dist/index.js",
"scripts": {
Expand Down
26 changes: 26 additions & 0 deletions src/generate-report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ interface ReporterConfigOptions {
osVersion?: string | undefined
buildName?: string | undefined
buildNumber?: string | undefined
buildUrl?: string | undefined
repositoryName?: string | undefined
repositoryUrl?: string | undefined
branchName?: string | undefined
testEnvironment?: string | undefined
}

class GenerateCtrfReport implements Reporter {
Expand All @@ -55,6 +60,11 @@ class GenerateCtrfReport implements Reporter {
osVersion: config?.osVersion ?? undefined,
buildName: config?.buildName ?? undefined,
buildNumber: config?.buildNumber ?? undefined,
buildUrl: config?.buildUrl ?? undefined,
repositoryName: config?.repositoryName ?? undefined,
repositoryUrl: config?.repositoryUrl ?? undefined,
branchName: config?.branchName ?? undefined,
testEnvironment: config?.testEnvironment ?? undefined,
}

this.ctrfReport = {
Expand Down Expand Up @@ -239,6 +249,22 @@ class GenerateCtrfReport implements Reporter {
if (reporterConfigOptions.buildNumber !== undefined) {
this.ctrfEnvironment.buildNumber = reporterConfigOptions.buildNumber
}
if (reporterConfigOptions.buildUrl !== undefined) {
this.ctrfEnvironment.buildUrl = reporterConfigOptions.buildUrl
}
if (reporterConfigOptions.repositoryName !== undefined) {
this.ctrfEnvironment.repositoryName = reporterConfigOptions.repositoryName
}
if (reporterConfigOptions.repositoryUrl !== undefined) {
this.ctrfEnvironment.repositoryUrl = reporterConfigOptions.repositoryUrl
}
if (reporterConfigOptions.branchName !== undefined) {
this.ctrfEnvironment.branchName = reporterConfigOptions.branchName
}
if (reporterConfigOptions.testEnvironment !== undefined) {
this.ctrfEnvironment.testEnvironment =
reporterConfigOptions.testEnvironment
}
}

hasEnvironmentDetails(environment: CtrfEnvironment): boolean {
Expand Down
5 changes: 5 additions & 0 deletions types/ctrf.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ export interface CtrfEnvironment {
osVersion?: string
buildName?: string
buildNumber?: string
buildUrl?: string
repositoryName?: string
repositoryUrl?: string
branchName?: string
testEnvironment?: string
extra?: Record<string, any>
}

Expand Down

0 comments on commit 2e03bce

Please sign in to comment.