Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add annotations #8

Merged
merged 2 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading