Skip to content

Commit

Permalink
docs: add info about pw and allure reporters
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalets committed Oct 21, 2024
1 parent cbad130 commit b2532f4
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 25 deletions.
4 changes: 3 additions & 1 deletion docs/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Binary file added docs/reporters/_media/allure-report.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/reporters/_media/pw-html-report.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions docs/reporters/allure.md
Original file line number Diff line number Diff line change
@@ -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)
10 changes: 3 additions & 7 deletions docs/reporters/cucumber.md
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -12,20 +10,18 @@ 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.

<details><summary>Example HTML report with auto-attachments</summary>
<details><summary>Example of HTML report with attached screenshot, video and trace</summary>

![html report](./_media/html-report-attachments.png)

</details>

#### 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:

Expand Down
21 changes: 4 additions & 17 deletions docs/reporters/index.md
Original file line number Diff line number Diff line change
@@ -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).

32 changes: 32 additions & 0 deletions docs/reporters/playwright.md
Original file line number Diff line number Diff line change
@@ -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).

3 changes: 3 additions & 0 deletions src/reporter/cucumber/custom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {},
},
Expand Down

0 comments on commit b2532f4

Please sign in to comment.