Skip to content

Commit

Permalink
feat: add env properties
Browse files Browse the repository at this point in the history
  • Loading branch information
Ma11hewThomas committed Jun 7, 2024
1 parent 769b70e commit 37c1100
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 15 deletions.
31 changes: 17 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,21 +133,24 @@ The reporter supports several configuration options:

```javascript
new GenerateCtrfReport({
on, {
outputFile: 'custom-name.json', // Optional: Output file name. Defaults to 'ctrf-report.json'.
outputDir: 'custom-directory', // Optional: Output directory path. Defaults to 'ctrf'.
minimal: true, // Optional: Generate a minimal report. Defaults to 'false'. Overrides screenshot and testType when set to true
testType: 'e2e', // Optional: Specify the test type (e.g., 'api', 'e2e'). Defaults to 'e2e'.
appName: 'MyApp', // Optional: Specify the name of the application under test.
appVersion: '1.0.0', // Optional: Specify the version of the application under test.
osPlatform: 'linux', // Optional: Specify the OS platform.
osRelease: '18.04', // Optional: Specify the OS release version.
osVersion: '5.4.0', // Optional: Specify the OS version.
buildName: 'MyApp Build', // Optional: Specify the build name.
buildNumber: '100', // Optional: Specify the build number.
}
on,
outputFile: 'custom-name.json', // Optional: Output file name. Defaults to 'ctrf-report.json'.
outputDir: 'custom-directory', // Optional: Output directory path. Defaults to 'ctrf'.
minimal: true, // Optional: Generate a minimal report. Defaults to 'false'. Overrides screenshot and testType when set to true
testType: 'e2e', // Optional: Specify the test type (e.g., 'api', 'e2e'). Defaults to 'e2e'.
appName: 'MyApp', // Optional: Specify the name of the application under test.
appVersion: '1.0.0', // Optional: Specify the version of the application under test.
osPlatform: 'linux', // Optional: Specify the OS platform.
osRelease: '18.04', // Optional: Specify the OS release version.
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).
})

```

## Test Object Properties
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": "cypress-ctrf-json-reporter",
"version": "0.0.8",
"version": "0.0.9",
"description": "",
"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
}

export class GenerateCtrfReport {
Expand Down Expand Up @@ -57,6 +62,11 @@ export class GenerateCtrfReport {
osVersion: reporterOptions?.osVersion ?? undefined,
buildName: reporterOptions?.buildName ?? undefined,
buildNumber: reporterOptions?.buildNumber ?? undefined,
buildUrl: reporterOptions?.buildUrl ?? undefined,
repositoryName: reporterOptions?.repositoryName ?? undefined,
repositoryUrl: reporterOptions?.repositoryUrl ?? undefined,
branchName: reporterOptions?.branchName ?? undefined,
testEnvironment: reporterOptions?.testEnvironment ?? undefined,
}
this.ctrfReport = {
results: {
Expand Down Expand Up @@ -208,6 +218,22 @@ export class GenerateCtrfReport {
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 37c1100

Please sign in to comment.