diff --git a/docs/_sidebar.md b/docs/_sidebar.md index 7445d0ea..d50bbd67 100644 --- a/docs/_sidebar.md +++ b/docs/_sidebar.md @@ -23,7 +23,9 @@ - [Snippets](writing-steps/snippets.md) * [**Reporters**](reporters/index.md) - - [Cucumber reporters](reporters/cucumber.md) + - [Playwright](reporters/playwright.md) + - [Cucumber](reporters/cucumber.md) + - [Allure](reporters/allure.md) * [**Guides**](guides/index.md) - [Migration to v7](guides/migration-v7.md) diff --git a/docs/reporters/_media/allure-report.png b/docs/reporters/_media/allure-report.png new file mode 100644 index 00000000..fc99120c Binary files /dev/null and b/docs/reporters/_media/allure-report.png differ diff --git a/docs/reporters/_media/pw-html-report.png b/docs/reporters/_media/pw-html-report.png new file mode 100644 index 00000000..bb7d7f63 Binary files /dev/null and b/docs/reporters/_media/pw-html-report.png differ diff --git a/docs/reporters/allure.md b/docs/reporters/allure.md new file mode 100644 index 00000000..ecd78973 --- /dev/null +++ b/docs/reporters/allure.md @@ -0,0 +1,28 @@ +# Allure reporter + +You can output test results with [allure-playwright](https://www.npmjs.com/package/allure-playwright) reporter (not `allure-cucumberjs`). Follow the instructions from allure website: [install](https://allurereport.org/docs/install/) allure itself, install allure-playwright and enable it in the config: + +```js +import { defineConfig } from '@playwright/test'; +import { defineBddConfig } from 'playwright-bdd'; + +const testDir = defineBddConfig({ /* BDD config */ }); + +export default defineConfig({ + testDir, + reporter: 'allure-playwright', // <- enable allure reporter +}); +``` + +Feature file: +```gherkin +Feature: Playwright Home Page + + Scenario: Check title + Given I am on Playwright home page + When I click link "Get started" + Then I see in title "Installation" +``` + +Allure report: +![Allure report](./_media/allure-report.png) diff --git a/docs/reporters/cucumber.md b/docs/reporters/cucumber.md index 4d42045d..0465ae07 100644 --- a/docs/reporters/cucumber.md +++ b/docs/reporters/cucumber.md @@ -1,7 +1,5 @@ # Cucumber reporters -?> Cucumber reporters is a new feature, feel free to share your feedback in [issues](https://github.com/vitalets/playwright-bdd/issues) - Playwright-bdd provides special adapter to output test results with [Cucumber reporters (formatters)](https://github.com/cucumber/cucumber-js/blob/main/docs/formatters.md). Currently, the following reporters are supported: @@ -12,12 +10,10 @@ Currently, the following reporters are supported: * [message](#message) * [custom](#custom) -Navigate to the concrete reporter for the usage details. - #### Automatic screenshots / videos / traces -Playwright-bdd fully supports [auto attaching screenshots, videos and traces](https://playwright.dev/docs/test-use-options#recording-options) to all Cucumber reports. No special action needed from your side. +Playwright-bdd fully supports auto-attaching of **screenshots**, **videos** and **traces** to all Cucumber reports. All you need is to [enable these options](https://playwright.dev/docs/test-use-options#recording-options) in Playwright config. -
Example HTML report with auto-attachments +
Example of HTML report with attached screenshot, video and trace ![html report](./_media/html-report-attachments.png) @@ -25,7 +21,7 @@ Playwright-bdd fully supports [auto attaching screenshots, videos and traces](ht #### Projects -Cucumber formatters don't natively support Playwright's [projects concept](https://playwright.dev/docs/test-projects#introduction). Nevertheless, playwright-bdd adopts Playwright test results and shows all projects in a single Cucumber report. +Cucumber formatters don't natively support [projects concept](https://playwright.dev/docs/test-projects#introduction) that exists in Playwright. Nevertheless, playwright-bdd adopts test results to show projects in a Cucumber report. The final output depends on the particular reporter. For example, in HTML reporter project name is prepended to the feature file path: diff --git a/docs/reporters/index.md b/docs/reporters/index.md index bb06e78d..ae21695a 100644 --- a/docs/reporters/index.md +++ b/docs/reporters/index.md @@ -1,21 +1,8 @@ # Reporters -All [Playwright reporters](https://playwright.dev/docs/test-reporters) are supported out-of-box. Define `reporter` option in `playwright.config.ts` as usual: +Playwright-bdd provides many reporting options: +- native [Playwright reporters](reporters/playwright.md) +- [Cucumber reporters](reporters/cucumber.md) +- third-party reporters like [Allure](reporters/allure.md) -```js -import { defineConfig } from '@playwright/test'; -import { defineBddConfig } from 'playwright-bdd'; - -const testDir = defineBddConfig({ - features: 'sample.feature', - steps: 'steps.js', -}); - -export default defineConfig({ - testDir, - reporter: 'html', // <- define reporter as usual -}); -``` - -If you need more BDD-adopted reports, have a look on [Cucumber reporters](reporters/cucumber.md). diff --git a/docs/reporters/playwright.md b/docs/reporters/playwright.md new file mode 100644 index 00000000..7fabc59d --- /dev/null +++ b/docs/reporters/playwright.md @@ -0,0 +1,32 @@ +# Playwright reporters + +All [Playwright reporters](https://playwright.dev/docs/test-reporters) are supported out-of-box. They are less BDD-adopted, but contain all the latest features of Playwright reporting. + +Example of enabling Playwright HTML reporter: +```js +import { defineConfig } from '@playwright/test'; +import { defineBddConfig } from 'playwright-bdd'; + +const testDir = defineBddConfig({ /* BDD config */ }); + +export default defineConfig({ + testDir, + reporter: 'html', // <- define reporter as usual +}); +``` + +Feature file: +```gherkin +Feature: Playwright Home Page + + Scenario: Check title + Given I am on Playwright home page + When I click link "Get started" + Then I see in title "Installation" +``` + +Report: +![Playwright html report](./_media/pw-html-report.png) + +If you need more BDD-adopted reports, have a look on [Cucumber reporters](reporters/cucumber.md). + diff --git a/src/reporter/cucumber/custom.ts b/src/reporter/cucumber/custom.ts index 868aabff..41c0474f 100644 --- a/src/reporter/cucumber/custom.ts +++ b/src/reporter/cucumber/custom.ts @@ -62,6 +62,9 @@ export default class CustomReporter extends BaseReporter { log: this.outputStream.write.bind(this.outputStream), cleanup: async () => {}, snippetBuilder: null, + // Build truncated supportCodeLibrary object. It can lead to errors in custom reporters. + // For full object see: + // https://github.com/cucumber/cucumber-js/blob/main/src/support_code_library_builder/types.ts#L160 supportCodeLibrary: { World: {}, },