Skip to content

Commit

Permalink
Merge pull request #8 from ctrf-io/feat/annotations
Browse files Browse the repository at this point in the history
feat: add annotations fixes #8
  • Loading branch information
Ma11hewThomas authored Sep 12, 2024
2 parents 9887dc4 + f52a2ae commit db84dde
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.17",
"version": "0.0.18",
"description": "A Playwright JSON test reporter to create test results reports",
"main": "dist/index.js",
"scripts": {
Expand Down
5 changes: 5 additions & 0 deletions src/generate-report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ interface ReporterConfigOptions {
outputDir?: string
minimal?: boolean
screenshot?: boolean
annotations?: boolean
testType?: string
appName?: string | undefined
appVersion?: string | undefined
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit db84dde

Please sign in to comment.