diff --git a/README.md b/README.md index 9551925..26fb799 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,7 @@ reporter: [ outputDir: 'custom-directory', // Optional: Output directory path. Defaults to '.' (project root). minimal: true, // Optional: Generate a minimal report. Defaults to 'false'. Overrides screenshot and testType when set to true screenshot: false, // Optional: Include screenshots in the report. Defaults to 'false'. + annotations: false, // Optional: Include annotations in the report. Defaults to 'false'. 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. @@ -159,6 +160,10 @@ The test object in the report includes the following [CTRF properties](https://c Some features require additional setup or usage considerations. +### Annotations + +By setting `annotations: true` you can include annotations in the test extra property. + ### Screenshots You can include base-64 screenshots in your test report, you'll need to capture and attach screenshots in your Playwright tests: diff --git a/package-lock.json b/package-lock.json index c92b286..43a25e0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "playwright-ctrf-json-reporter", - "version": "0.0.17", + "version": "0.0.18", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "playwright-ctrf-json-reporter", - "version": "0.0.17", + "version": "0.0.18", "license": "MIT", "devDependencies": { "@playwright/test": "^1.39.0", diff --git a/package.json b/package.json index 8629fd6..95d6a09 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "playwright-ctrf-json-reporter", - "version": "0.0.17", + "version": "0.0.18", "description": "A Playwright JSON test reporter to create test results reports", "main": "dist/index.js", "scripts": { diff --git a/src/generate-report.ts b/src/generate-report.ts index ad7bd87..b14c7db 100644 --- a/src/generate-report.ts +++ b/src/generate-report.ts @@ -22,6 +22,7 @@ interface ReporterConfigOptions { outputDir?: string minimal?: boolean screenshot?: boolean + annotations?: boolean testType?: string appName?: string | undefined appVersion?: string | undefined @@ -53,6 +54,7 @@ class GenerateCtrfReport implements Reporter { outputDir: config?.outputDir ?? this.defaultOutputDir, minimal: config?.minimal ?? false, screenshot: config?.screenshot ?? false, + annotations: config?.annotations ?? false, testType: config?.testType ?? 'e2e', appName: config?.appName ?? undefined, appVersion: config?.appVersion ?? undefined, @@ -204,6 +206,9 @@ class GenerateCtrfReport implements Reporter { ) test.browser = `${this.extractMetadata(testResult) ?.name} ${this.extractMetadata(testResult)?.version}` + if (this.reporterConfigOptions.annotations !== undefined) { + test.extra = { annotations: testCase.annotations } + } } ctrfReport.results.tests.push(test)