diff --git a/packages/allure-codeceptjs/README.md b/packages/allure-codeceptjs/README.md index 6fde232b1..fdb270099 100644 --- a/packages/allure-codeceptjs/README.md +++ b/packages/allure-codeceptjs/README.md @@ -12,173 +12,103 @@ --- -## Installation - -```bash -npm i -D allure-codeceptjs -``` +## The documentation and examples -## Usage +The docs for Allure CodeceptJS are available at [https://allurereport.org/docs/codeceptjs/](https://allurereport.org/docs/codeceptjs/). -Add the allure plugin inside you plugins section of your CodeceptJS config file. -For instance the config file is `codecept.config.(js|ts)` then: +Also, check out the examples at [github.com/allure-examples](https://github.com/orgs/allure-examples/repositories?q=visibility%3Apublic+archived%3Afalse+topic%3Aexample+topic%3Acodeceptjs). -```js -module.exports.config = { - plugins: { - // ... - allure: { - enabled: true, - require: "allure-codeceptjs", - }, - // ... - } -}; -``` - -## Allure Runtime API usage +## Installation -Right now you can access allure API through codeceptjs container. +Install `allure-codeceptjs` using a package manager of your choice. For example: -```js -import { label, tag, tags, issue, owner, layer, allureId, description, story, feature, epic, attachment } from "allure-js-commons"; - -Feature("login-feature"); -Scenario("login-scenario1", async () => { - await label("name", "value"); - await tag("tag1"); - await tags("tag2", "tag3"); - await issue("issueName", "google.com"); - await owner("eroshenkoam"); - await layer("UI"); - await allureId("228"); - await description("aga"); - await story("aga"); - await feature("aga"); - await epic("aga"); - await attachment("data.txt", "some data", "text/plain"); -}); +```bash +npm install -D allure-codeceptjs ``` -You can also use tags to manage labels on scenarios. +## Usage -## Links usage +Enable the `allure` plugin in [the CodeceptJS configuration file](https://codecept.io/configuration/): ```js -import { link, issue, tms } from "allure-js-commons"; - -Feature("login-feature"); -Scenario("login-scenario1", async () => { - await link("link_type", "https://allurereport.org", "Allure Report"); - await issue("Issue Name", "https://github.com/allure-framework/allure-js/issues/352"); - await tms("Task Name", "https://github.com/allure-framework/allure-js/tasks/352"); -}); -``` - -You can also configure links formatters to make usage much more convenient. `%s` -in `urlTemplate` parameter will be replaced by given value. - -```diff module.exports.config = { - // ... plugins: { allure: { enabled: true, require: "allure-codeceptjs", -+ links: [ -+ { -+ type: "${LinkType.ISSUE}", -+ urlTemplate: "https://example.org/issues/%s", -+ nameTemplate: "Issue: %s", -+ }, -+ { -+ type: "${LinkType.TMS}", -+ urlTemplate: "https://example.org/tasks/%s", -+ } -+ ] }, + + // Other plugins... }, - // ... + + // Other CodeceptJS options... }; ``` -Then you can assign link using shorter notation: +When the test run completes, the result files will be generated in the `./allure-results` directory. -```js -import { link, issue, tms } from "allure-js-commons"; - -Feature("login-feature"); -Scenario("login-scenario1", async () => { - await issue("351"); - await issue("352", "Issue Name"); - await tms("351"); - await tms("352", "Task Name"); - await link("custom", "352"); - await link("custom", "352", "Link name"); -}); -``` +You may select another location, or further customize the plugin's behavior with [the configuration options](https://allurereport.org/docs/codeceptjs-configuration/). -## Tags metadata API +### View the report -You also can mark up your tests with Allure metadata using CodeceptJS tags API. +> You need Allure Report to be installed on your machine to generate and open the report from the result files. See the [installation instructions](https://allurereport.org/docs/install/) on how to get it. -### Id - -```javascript -Feature("login-feature"); -Scenario("login-scenario1", async () => { - // your test -}).tag("@allure.id:228"); -``` +Generate Allure Report after the tests are executed: -### Label - -```javascript -Feature("login-feature"); -Scenario("login-scenario1", async () => { - // your test -}).tag("@allure.label.{{labelName}}:{{labelValue}}"); +```bash +allure generate ./allure-results -o ./allure-report ``` -### Story +Open the generated report: -```javascript -Feature("login-feature"); -Scenario("login-scenario1", async () => { - // your test -}).tag("@allure.label.story:storyName"); -``` -### Suite - -```javascript -Feature("login-feature"); -Scenario("login-scenario1", async () => { - // your test -}).tag("@allure.label.suite:suiteName"); +```bash +allure open ./allure-report ``` -### Owner +## Allure API -```javascript -Feature("login-feature"); -Scenario("login-scenario1", async () => { - // your test -}).tag("@allure.label.owner:ownerName"); -``` - -### Tag +Enhance the report by utilizing the Allure API: -```javascript -Feature("login-feature"); -Scenario("login-scenario1", async () => { - // your test -}).tag("@allure.label.tag:tagName"); +```js +import * as allure from "allure-js-commons"; + +Feature("Signing in with a password"); +Scenario("Signing in with a correct password", async () => { + await allure.description("The test checks if an active user with a valid password can sign in to the app."); + await allure.epic("Signing in"); + await allure.tags("signin", "ui", "positive"); + await allure.issue("https://github.com/allure-framework/allure-js/issues/673", "ISSUE-673"); + await allure.owner("eroshenkoam"); + await allure.parameter("browser", "chrome"); + + const user = await allure.step("Prepare the user", async () => { + return await createAnActiveUserInDb(); + }); + + await allure.step("Make a sign-in attempt", async () => { + await allure.step("Navigate to the sign-in page", async () => { + // ... + }); + + await allure.step("Fill the sign-in form", async (stepContext) => { + await stepContext.parameter("login", user.login); + await stepContext.parameter("password", user.password, "masked"); + + // ... + }); + + await allure.step("Submit the form", async () => { + // ... + // const responseData = ... + + await allure.attachment("response", JSON.stringify(responseData), { contentType: "application/json" }); + }); + }); + + await allure.step("Assert the signed-in state", async () => { + // ... + }); +}); ``` -or keep it simple: -```javascript -Feature("login-feature"); -Scenario("login-scenario1", async () => { - // your test -}).tag("tagName"); -``` +More details about the API are available at [https://allurereport.org/docs/codeceptjs-reference/](https://allurereport.org/docs/codeceptjs-reference/). diff --git a/packages/allure-cucumberjs/README.md b/packages/allure-cucumberjs/README.md index 15059be8e..a61004055 100644 --- a/packages/allure-cucumberjs/README.md +++ b/packages/allure-cucumberjs/README.md @@ -12,217 +12,102 @@ --- -## Installation - -Install the required packages using your favorite package manager: - -```shell -npm add -D allure-cucumberjs -``` - -Create `reporter.js` with following content: - -```js -// reporter.js -const AllureCucumberReporter = require("allure-cucumberjs/reporter"); +## The documentation and examples -export default AllureCucumberReporter; -``` +The docs for Allure Cucumber.js are available at +[https://allurereport.org/docs/cucumberjs/](https://allurereport.org/docs/cucumberjs/). -Then add following lines to the CucumberJS configuration file: +Also, check out the examples at [github.com/allure-examples](https://github.com/orgs/allure-examples/repositories?q=visibility%3Apublic+archived%3Afalse+topic%3Aexample+topic%3Acucumberjs). -```diff -// config.js -export default { -+ format: "./path/to/reporter.js", -}; -``` +## Installation -And then run CLI with `config` parameter: +Install `allure-cucumberjs` using a package manager of your choice. For example: ```shell -cucumber-js --config ./config.js +npm install -D allure-cucumberjs ``` -## Reporter options +> If you're a Yarn PnP user, please read [this](https://allurereport.org/docs/cucumberjs-configuration/#a-note-for-yarn-pnp-users). -Some reporter settings can be set by following options: +## Usage -| Option | Description | Default | -| ---------- |-------------------------------------------------------------------------------------------------| ------------------ | -| resultsDir | Path to results folder | `./allure-results` | -| links | Links templates to make runtime methods calls simpler and process Cucumber tags as Allure links | `undefined` | -| labels | Labels templates to process Cucumber tags as Allure labels | `undefined` | +Enable the `allure-cucumberjs/reporter` formatter in [the Cucumber.js configuration file](https://github.com/cucumber/cucumber-js/blob/main/docs/configuration.md): -## Using Allure API - -To start using Allure Runtime API you need to add the following import into your `./feature/support/world.js` file: - -```js -import "allure-cucumberjs"; +```json +{ + "default": { + "format": [ + "allure-cucumberjs/reporter" + ] + } +} ``` -Then, you can call Allure Runtime API methods directly in your step definitions: +> Alternatively, you may specify the formatter via the CLI: +> ```shell +> npx cucumber-js --format allure-cucumberjs/reporter +> ``` -```js -import { Given } from "@cucumber/cucumber"; -import { label, attachment, step } from "allure-js-commons"; +When the test run completes, the result files will be generated in the `./allure-results` directory. -Given(/my step/, async () => { - await step("step can have anonymous body function", async () => { - await label("label_name", "label_value"); - await attachment(JSON.stringify({ foo: "bar " }), "application/json"); - }); +IYou may select another location, or further customize the formatter's behavior with [the configuration options](https://allurereport.org/docs/cucumberjs-configuration/). - await step("by the way, body function can be arrow one", async () => { - await label("label_name", "label_value"); - await attachment(JSON.stringify({ foo: "bar " }), "application/json"); - }); -}); -``` - -### Using Allure Cucumber World +### View the report -If you prefer to use custom Allure World instead of global Allure API, you can use `AllureCucumberWorld` class: +> You need Allure Report to be installed on your machine to generate and open the report from the result files. See the [installation instructions](https://allurereport.org/docs/install/) on how to get it. -```js -import { AllureCucumberWorld } from "allure-cucumberjs"; -import { setWorldConstructor } from "@cucumber/cucumber"; - -setWorldConstructor(AllureCucumberWorld); -``` - -Then you'll be able to use Allure Runtime API through `this` in your step definition files: - -```js -import { Given } from "@cucumber/cucumber"; - -Given(/my step/, async function() { - const self = this; - - await self.step("step can have anonymous body function", async function() { - await self.label("label_name", "label_value"); - await self.attachment(JSON.stringify({ foo: "bar " }), "application/json"); - }); +Generate Allure Report after the tests are executed: - await self.step("by the way, body function can be arrow one", async function() { - await self.label("label_name", "label_value"); - await self.attachment(JSON.stringify({ foo: "bar " }), "application/json"); - }); -}); +```bash +allure generate ./allure-results -o ./allure-report ``` -If you run your Cucumber features using single thread mode, `AllureCucumberWorld` is set automatically. +Open the generated report: -### Links usage - -```js -const { Given } = require("@cucumber/cucumber"); -import { link, issue, tms } from "allure-js-commons"; - -Given("step name", async () => { - await link("link_type", "https://allurereport.org", "Allure Report"); - await issue("Issue Name", "https://github.com/allure-framework/allure-js/issues/352"); - await tms("Task Name", "https://github.com/allure-framework/allure-js/tasks/352"); -}); +```bash +allure open ./allure-report ``` -You can also configure links formatters to make usage much more convenient. `%s` -in `urlTemplate` parameter will be replaced by given value. - -```diff -// config.js -export default { - format: "./path/to/reporter.js", -+ formatOptions: { -+ links: [ -+ { -+ pattern: [/@issue=(.*)/], -+ type: "issue", -+ urlTemplate: "https://example.com/issues/%s", -+ nameTemplate: "Issue: %s", -+ }, -+ { -+ pattern: [/@tms=(.*)/], -+ type: "tms", -+ urlTemplate: "https://example.com/tasks/%s", -+ }, -+ ], -+ } -}; -``` +## Allure API -Then you can assign link using shorter notation: +Enhance the report by utilizing the Allure API: ```js -const { Given } = require("@cucumber/cucumber"); -import { link, issue, tms } from "allure-js-commons"; - -Given("step name", async () => { - await issue("351"); - await issue("352", "Issue Name"); - await tms("351"); - await tms("352", "Task Name"); - await link("custom", "352"); - await link("custom", "352", "Link name"); +import { When } from "@cucumber/cucumber"; +import * as allure from "allure-js-commons"; + +Given("an active user", async function () { + await allure.description("The test checks if an active user with a valid password can sign in to the app."); + await allure.epic("Signing in"); + await allure.tags("signin", "ui", "positive"); + await allure.issue("https://github.com/allure-framework/allure-js/issues/1", "ISSUE-1"); + await allure.owner("eroshenkoam"); + await allure.parameter("browser", "chrome"); + + this.user = await createAnActiveUserInDb(); }); -``` - -Links patterns also work with Cucumber tags which match `pattern` parameter: - -```gherkin -@issue=0 -Feature: links - - @issue=1 @tms=2 - Scenario: a - Given a step -``` - -### Parameters usage - -```ts -import { Given } from "@cucumber/cucumber"; -import { step, parameter } from "allure-js-commons"; -Given(/my step/, async () => { - await step("step can have anonymous body function", async () => { - await parameter("parameterName", "parameterValue"); +When("they sign in with a valid password", async function () { + await allure.step("Navigate to the sign in page", async () => { + // ... }); -}); -``` -Also addParameter takes an third optional parameter with the hidden and excluded options: + await allure.step("Fill the sign-in form", async (stepContext) => { + await stepContext.parameter("login", this.user.login); + await stepContext.parameter("password", this.user.password, "masked"); -`mode: "hidden" | "masked"` - `masked` hide parameter value to secure sensitive data, and `hidden` entirely hide parameter from report - -`excluded: true` - excludes parameter from the history + // ... + }); -```ts -import { Given } from "@cucumber/cucumber"; -import { step, parameter } from "allure-js-commons"; + await allure.step("Submit the form", async () => { + // ... + // const responseData = ... -Given(/my step/, async () => { - await step("step can have anonymous body function", async () => { - await parameter("parameterName", "parameterValue", { mode: "hidden", excluded: true }); + await allure.attachment("response", JSON.stringify(responseData), { contentType: "application/json" }); }); }); -``` - -## Cross-browser testing - -For cross-browser testing simply add a parameter using Allure API with the browser name to the `World` instance inside your scenario, i.e.: -```js -import { parameter } from "allure-js-commons"; - -await parameter('Browser', 'firefox') +// ... ``` -For better presentation, you can also group suites by browser names, i.e.: - -```js -import { parentSuite } from "allure-js-commons"; - -await parentSuite('Firefox') -``` +More details about the API are available at [https://allurereport.org/docs/cucumberjs-reference/](https://allurereport.org/docs/cucumberjs-reference/). diff --git a/packages/allure-cypress/README.md b/packages/allure-cypress/README.md index d2afaaacd..205e4fe88 100644 --- a/packages/allure-cypress/README.md +++ b/packages/allure-cypress/README.md @@ -12,15 +12,21 @@ --- +## The documentation + +The docs for Allure Cypress are available at [https://allurereport.org/docs/cypress/](https://allurereport.org/docs/cypress/). + ## Installation -Use your favorite Node.js package manager to install the required packages: +Install `allure-cypress` using a package manager of your choice. For example: ```shell -npm add -D allure-cypress +npm install -D allure-cypress ``` -Add the following lines to your `cypress.config.js` file: +## Usage + +Call `allureCypress` to initialize the plugin from the `setupNodeEvents` function in `cypress.config.js`: ```javascript import { defineConfig } from "cypress"; @@ -44,13 +50,13 @@ Import `allure-cypress` in `cypress/support/e2e.js`: import "allure-cypress"; ``` -Allure Cypress is ready to run now. When the test run completes, the result files -will be collected in the `./allure-results` directory. If you want to use another -location, provide it via the `resultsDir` configuration option ([see below](#allure-cypress-options)). +When the test run completes, the result files will be generated in the `./allure-results` directory. + +You may select another location, or further customize the plugin's behavior with [the configuration options](https://allurereport.org/docs/cypress-configuration/). ### View the report -> You need Allure Report to generate and open the report from result files. See the [installation instructions](https://allurereport.org/docs/install/) for more details. +> You need Allure Report to be installed on your machine to generate and open the report from the result files. See the [installation instructions](https://allurereport.org/docs/install/) on how to get it. Generate Allure Report: @@ -64,85 +70,56 @@ Open Allure Report: allure open ./allure-report ``` -## The documentation - -Learn more about Allure Cypress from the official documentation at -[https://allurereport.org/docs/cypress/](https://allurereport.org/docs/cypress/). - - -## Allure Cypress options - -Customize Allure Cypress by providing a configuration object as the third argument -of `allureCypress`. - -The following options are supported: +## Allure API -| Option | Description | Default | -|-------------------|----------------------------------------------------------------------------------------------------------------------|---------------------------------| -| resultsDir | The path of the results folder. | `./allure-results` | -| videoOnFailOnly | When video capturing is enabled, set this option to `true` to attach the video to failed specs only. | `false` | -| links | Allure Runtime API link templates. | `undefined` | -| stepsFromCommands | Options that affect how Allure creates steps from Cypress commands | See [below](#stepsfromcommands) | -| environmentInfo | A set of key-value pairs to display in the Environment section of the report | `undefined` | -| categories | An array of category definitions, each describing a [category of defects](https://allurereport.org/docs/categories/) | `undefined` | +Enhance the report by utilizing the Allure API: -### stepsFromCommands +```js +import * as allure from "allure-js-commons"; -| Property | Description | Default | -|-------------------|---------------------------------------------------------------------------------------------------------------------------------------------|---------| -| maxArgumentLength | The maximum length of the parameter value created from Cypress command argument. The rest of the characters are replaces with `...`. | 128 | -| maxArgumentDepth | The maximum depth of the Cypress command argument (an array or an object) that will be converted to the corresponding step parameter value. | 3 | +describe("signing in with a password", () => { + it("should sign in with a valid password", () => { + allure.description("The test checks if an active user with a valid password can sign in to the app."); + allure.epic("Signing in"); + allure.feature("Sign in with a password"); + allure.story("As an active user, I want to successfully sign in using a valid password"); + allure.tags("signin", "ui", "positive"); + allure.issue("https://github.com/allure-framework/allure-js/issues/900", "ISSUE-900"); + allure.owner("eroshenkoam"); + allure.parameter("browser", Cypress.browser.family); + allure.step("Prepare the user", () => { + return createAnActiveUserInDb(); + }).then((user) => { + allure.step("Make a sign-in attempt", () => { + allure.step("Navigate to the sign-in page", () => { + // ... + }); -### Example + allure.step("Fill the sign-in form", (stepContext) => { + stepContext.parameter("login", user.login); + stepContext.parameter("password", user.password, "masked"); -Here is an example of the Allure Cypress configuration: + // ... + }); -```javascript -import { defineConfig } from "cypress"; -import { allureCypress } from "allure-cypress/reporter"; + allure.step("Submit the form", () => { + // ... -export default defineConfig({ - e2e: { - setupNodeEvents: (on, config) => { - allureCypress(on, config, { - resultsDir: "my-allure-results", - videoOnFailOnly: true, - links: { - link: { - urlTemplate: "https://github.com/allure-framework/allure-js/blob/main/%s", - }, - issue: { - urlTemplate: "https://github.com/allure-framework/allure-js/issues/%s", - nameTemplate: "ISSUE-%s", - }, - }, - stepsFromCommands: { - maxArgumentLength: 64, - maxArgumentDepth: 5, - }, - environmentInfo: { - OS: os.platform(), - Architecture: os.arch(), - NodeVersion: process.version, - }, - categories: [ - { - name: "Missing file errors", - messageRegex: /^ENOENT: no such file or directory/, - }, - ], + allure.attachment("cookies", JSON.stringify(cy.getCookies()), { contentType: "application/json" }); + }); }); + - return config; - }, - // other Cypress config properties ... - }, + allure.step("Assert the signed-in state", () => { + // ... + }); + }); + }); }); ``` -More details about Allure Cypress configuration are available at [https://allurereport.org/docs/cypress-configuration/](https://allurereport.org/docs/cypress-configuration/). - +More details about the API are available at [https://allurereport.org/docs/cypress-reference/](https://allurereport.org/docs/cypress-reference/). ## Combining Allure with other Cypress plugins @@ -223,8 +200,7 @@ Allure Cypress requires access to the following events: Otherwise, it may not work as expected. -If you need to define your own handlers of those events, make sure to call the -corresponding functions of the `allureCypress`s' return value: +If you need to define your own handlers of those events, make sure to call the corresponding functions of the `allureCypress`s' return value: ```javascript import { defineConfig } from "cypress"; @@ -255,7 +231,6 @@ export default defineConfig({ ``` If you want to combine Allure Cypress with other plugins, consider using -[cypress-on-fix](https://github.com/bahmutov/cypress-on-fix). See the example for -[the Cypress Cucumber preprocessor](#combining-allure-with-other-cypress-plugins) above. +[cypress-on-fix](https://github.com/bahmutov/cypress-on-fix). See the example for [the Cypress Cucumber preprocessor](#combining-allure-with-other-cypress-plugins) above. You may read more details and workarounds in issues [cypress-io/cypress#5240](https://github.com/cypress-io/cypress/issues/5240) and [cypress-io/cypress#22428](https://github.com/cypress-io/cypress/issues/22428). diff --git a/packages/allure-jasmine/README.md b/packages/allure-jasmine/README.md index 5a8e4babe..dc625fe2e 100644 --- a/packages/allure-jasmine/README.md +++ b/packages/allure-jasmine/README.md @@ -12,110 +12,99 @@ --- +## The documentation + +The docs for Allure Jasmine are available at [https://allurereport.org/docs/jasmine/](https://allurereport.org/docs/jasmine/). + ## Installation -Use your favorite node package manager to install required packages: +Install `allure-jasmine` using a package manager of your choice. For example: ```bash -npm add -D allure-jasmine +npm install -D allure-jasmine ``` -Create `spec/helpers/setup.ts` file with following content: +## Usage -```ts -const AllureJasmineReporter = require("allure-jasmine"); +Create a helper file (e.g., `helpers/setup.js` or `helpers/setup.ts`) and set up the Allure reporter in it: -const reporter = new AllureJasmineReporter(); +```ts +import AllureJasmineReporter from "allure-jasmine"; -jasmine.getEnv().addReporter(reporter); +jasmine.getEnv().addReporter( + new AllureJasmineReporter(), +); ``` -Check that the helper matches with `helper` field in your `spec/support/jasmine.json` file. - -## Use Allure runtime Api +> Make sure the helper file is matched against the `helpers` regular expression in [`spec/support/jasmine.json`](https://jasmine.github.io/setup/nodejs.html#configuration). -The plugin provides custom commands which allow to add additional info inside your tests: +When the test run completes, the result files will be generated in the `./allure-results` directory. -```javascript -import { epic, attachment, parameter } from "allure-js-commons"; +You may select another location, or further customize the reporter's behavior with [the configuration options](https://allurereport.org/docs/jasmine-configuration/). -it("my test", async () => { - await attachment("Attachment name", "Hello world!", "text/plain"); - await epic("my_epic"); - await parameter("parameter_name", "parameter_value", { - mode: "hidden", - excluded: false, - }); -}); -``` +### View the report -## Links usage +> You need Allure Report to be installed on your machine to generate and open the report from the result files. See the [installation instructions](https://allurereport.org/docs/install/) on how to get it. -```js -import { link, issue, tms } from "allure-js-commons"; +Generate Allure Report after the tests are executed: -it("basic test", async () => { - await link("https://allurereport.org", "link type", "Allure Report"); - await issue("https://github.com/allure-framework/allure-js/issues/352", "Issue Name", ); - await tms("https://github.com/allure-framework/allure-js/tasks/352", "Task Name"); -}); +```bash +allure generate ./allure-results -o ./allure-report ``` -You can also configure links formatters to make usage much more convenient. `%s` -in `urlTemplate` parameter will be replaced by given value. - -```diff -```ts -const AllureJasmineReporter = require("allure-jasmine"); - -const reporter = new AllureJasmineReporter({ -+ links: [ -+ { -+ type: "issue", -+ urlTemplate: "https://example.org/issues/%s", -+ nameTemplate: "Issue: %s", -+ }, -+ { -+ type: "tms", -+ urlTemplate: "https://example.org/tasks/%s" -+ }, -+ { -+ type: "custom", -+ urlTemplate: "https://example.org/custom/%s" -+ }, -+ ], -}); +Open the generated report: -jasmine.getEnv().addReporter(reporter); +```bash +allure open ./allure-report ``` -Then you can assign link using shorter notation: +## Allure API + +Enhance the report by utilizing the runtime API: ```js -import { link, issue, tms } from "allure-js-commons"; - -it("basic test", async () => { - await issue("351"); - await issue("352", "Issue Name"); - await tms("351"); - await tms("352", "Task Name"); - await link("custom", "352"); - await link("custom", "352", "Link name"); -}); -``` +import * as allure from "allure-js-commons"; + +describe("signing in with a password", () => { + it("should sign in with a valid password", async () => { + await allure.description("The test checks if an active user with a valid password can sign in to the app."); + await allure.epic("Signing in"); + await allure.feature("Sign in with a password"); + await allure.story("As an active user, I want to successfully sign in using a valid password"); + await allure.tags("signin", "ui", "positive"); + await allure.issue("https://github.com/allure-framework/allure-js/issues/1", "ISSUE-1"); + await allure.owner("eroshenkoam"); + await allure.parameter("browser", "chrome"); + + const user = await allure.step("Prepare the user", async () => { + return await createAnActiveUserInDb(); + }); -## Steps usage + await allure.step("Make a sign-in attempt", async () => { + await allure.step("Navigate to the sign in page", async () => { + // ... + }); -The integration supports Allure steps, use them in following way: + await allure.step("Fill the sign-in form", async (stepContext) => { + await stepContext.parameter("login", user.login); + await stepContext.parameter("password", user.password, "masked"); -```js -import { step } from "allure-js-commons"; + // ... + }); + + await allure.step("Submit the form", async () => { + // ... + // const responseData = ... -it("my test", async () => { - await step("foo", async () => { - await step("bar", async () => { - await step("baz", async () => {}); + await allure.attachment("response", JSON.stringify(responseData), { contentType: "application/json" }); + }); + }); + + await allure.step("Assert the signed-in state", async () => { + // ... }); }); }); ``` + +More details about the API are available at [https://allurereport.org/docs/jasmine-reference/](https://allurereport.org/docs/jasmine-reference/). diff --git a/packages/allure-jest/README.md b/packages/allure-jest/README.md index c82f4ea4a..1ceb8abc7 100644 --- a/packages/allure-jest/README.md +++ b/packages/allure-jest/README.md @@ -13,117 +13,113 @@ --- > **Warning** -> If you are using `jest@<27.0.0` use [`allure-jasmine` package][allure-jasmine] -> or consider to use `jest-circus` as a test runner with this package. -> -> The integration doesn't work with custom runners. If you want to use the -> integration use `jest-circus` as a test runner. +> This package only works with the [`jest-circus`](https://www.npmjs.com/package/jest-circus) test runner for Jest. It's the default runner for Jest starting from 27.0.0. If you use `jest@<27.0.0`, you should install `jest-circus` manually and set the [`testRunner`](https://jestjs.io/docs/configuration#testrunner-string) Jest option to `"jest-circus/runner"`. +> If you're a [`jest-jasmine2`](https://www.npmjs.com/package/jest-jasmine2) user, consider switching to `jest-circus`. If that's not an option for you, please use [allure-jasmine](https://allurereport.org/docs/jasmine/) instead. + +## The documentation and examples + +The docs for Allure Jest are available at [https://allurereport.org/docs/jest/](https://allurereport.org/docs/jest/). + +Also, check out the examples at [github.com/allure-examples](https://github.com/orgs/allure-examples/repositories?q=visibility%3Apublic+archived%3Afalse+topic%3Aexample+topic%3Ajest). ## Installation -Use your favorite node package manager to install the package: +Install `allure-jest` using a package manager of your choice. For example: ```shell -npm add -D allure-jest +npm install -D allure-jest ``` -If you're using `jest` for testing `node` add following line to your `jest.config.js` file: +> If you're a **Yarn PnP** user, you must also explicitly install the Jest environment package and `allure-js-commons`. For example: +> ```shell +> yarn add --dev jest-environment-node allure-js-commons +> ``` +> Keep in mind, that `allure-js-commons` and `allure-jest` must have the same version. The same goes for all Jest packages (`jest`, `jest-circus`, `jest-environment-node`, etc). Use [`yarn info`](https://yarnpkg.com/cli/info) to check the versions. -```diff -/** @type {import('jest').Config} */ -const config = { -+ testEnvironment: "allure-jest/node", -+ testEnvironmentOptions: { -+ resultsDir: "./allure-results" -+ } -} +## Usage -module.exports = config -``` +Set the [`testEnvironment`](https://jestjs.io/docs/configuration#testenvironment-string) Jest option according to your needs: -If you're using `jest` for testing browser code (`jsdom`) add next to your `jest.config.js` file: + - If you need access to DOM, set it to `"allure-jest/jsdom"` (make sure [jest-environment-jsdom](https://www.npmjs.com/package/jest-environment-jsdom) is installed). + - If you don't need access to DOM, set it to `"allure-jest/node"`. -```diff -/** @type {import('jest').Config} */ +Example: + +```js const config = { -+ testEnvironment: "allure-jest/jsdom", -+ testEnvironmentOptions: { -+ resultsDir: "./allure-results" -+ } -} + testEnvironment: "allure-jest/jsdom", +}; -module.exports = config +export default config; ``` -## Use Allure runtime Api +When the test run completes, the result files will be generated in the `./allure-results` directory. -The plugin provides custom global commands which allow to add additional info -inside your tests: +You may select another location, or further customize the behavior of Allure Jest with [the configuration options](https://allurereport.org/docs/jest-configuration/). -```javascript -import { attachment, epic, parameter } from "allure-js-commons"; +### View the report -it("my test", async () => { - await attachment(currentTest.id(), screenshot, "image/png"); - await epic(currentTest.id(), "my_epic"); - await parameter(currentTest.id(), "parameter_name", "parameter_value", { - mode: "hidden", - excluded: false, - }); -}); -``` - -## Links usage +> You need Allure Report to be installed on your machine to generate and open the report from the result files. See the [installation instructions](https://allurereport.org/docs/install/) on how to get it. -```js -import { link, issue } from "allure-js-commons"; +Generate Allure Report after the tests are executed: -it("basic test", async () => { - await link("https://allurereport.org", "Allure Report"); // link with name - await issue("Issue Name", "https://github.com/allure-framework/allure-js/issues/352"); -}); +```bash +allure generate ./allure-results -o ./allure-report ``` -You can also configure links formatters to make usage much more convenient. `%s` -in `urlTemplate` parameter will be replaced by given value. +Open the generated report: -```diff -/** @type {import('jest').Config} */ -const config = { - testEnvironment: "allure-jest/node", - testEnvironmentOptions: { - resultsDir: "./allure-results", -+ links: [ -+ { -+ type: "issue", -+ urlTemplate: "https://example.org/issues/%s", -+ nameTemplate: "Issue: %s", -+ }, -+ { -+ type: "tms", -+ urlTemplate: "https://example.org/tasks/%s" -+ }, -+ { -+ type: "custom", -+ urlTemplate: "https://example.org/custom/%s" -+ }, -+ ] - } -} - -module.exports = config +```bash +allure open ./allure-report ``` -Then you can assign link using shorter notation: +## Allure API -```js -import { issue, tms, link } from "allure-js-commons"; +Enhance the report by utilizing the runtime API: -it("basic test", async () => { - await issue("Issue Name", "352"); - await tms("Task Name", "352"); - await link("352", "Link name", "custom"); +```js +import * as allure from "allure-js-commons"; + +describe("signing in with a password", () => { + it("should sign in with a valid password", async () => { + await allure.description("The test checks if an active user with a valid password can sign in to the app."); + await allure.epic("Signing in"); + await allure.feature("Sign in with a password"); + await allure.story("As an active user, I want to successfully sign in using a valid password"); + await allure.tags("signin", "ui", "positive"); + await allure.issue("https://github.com/allure-framework/allure-js/issues/4", "ISSUE-4"); + await allure.owner("eroshenkoam"); + await allure.parameter("browser", "chrome"); + + const user = await allure.step("Prepare the user", async () => { + return await createAnActiveUserInDb(); + }); + + await allure.step("Make a sign-in attempt", async () => { + await allure.step("Navigate to the sign in page", async () => { + // ... + }); + + await allure.step("Fill the sign-in form", async (stepContext) => { + await stepContext.parameter("login", user.login); + await stepContext.parameter("password", user.password, "masked"); + + // ... + }); + + await allure.step("Submit the form", async () => { + // ... + // const responseData = ... + + await allure.attachment("response", JSON.stringify(responseData), { contentType: "application/json" }); + }); + }); + + await allure.step("Assert the signed-in state", async () => { + // ... + }); + }); }); ``` -[allure-jasmine]: https://github.com/allure-framework/allure-js/tree/master/packages/allure-jasmine +More details about the API are available at [https://allurereport.org/docs/jest-reference/](https://allurereport.org/docs/jest-reference/). diff --git a/packages/allure-mocha/README.md b/packages/allure-mocha/README.md index 3fa6bf9a4..0b2eb0b56 100644 --- a/packages/allure-mocha/README.md +++ b/packages/allure-mocha/README.md @@ -12,81 +12,104 @@ --- +## The documentation and examples + +The docs for Allure Mocha are available at [https://allurereport.org/docs/mocha/](https://allurereport.org/docs/mocha/). + +Also, check out the examples at [github.com/allure-examples](https://github.com/orgs/allure-examples/repositories?q=visibility%3Apublic+archived%3Afalse+topic%3Aexample+topic%3Amocha). + ## Installation -```bash -npm i allure-mocha mocha --save-dev +Install `allure-mocha` using a package manager of your choice. For example: + +```shell +npm install -D allure-mocha ``` -or via yarn: +## Usage + +Enable the `allure-mocha` reporter. For example, in `.mocharc.json`: + +```json +{ + "reporter": "allure-mocha" +}; +``` + +Alternatively, use the CLI. For example: ```bash -yarn add allure-mocha mocha --dev +npx mocha -R allure-mocha ``` -Note that it's recommended to add the following dependencies as well for better user experience: +When the test run completes, the result files will be generated in the `./allure-results` directory. -- typescript -- mocha-typescript -- source-map-support +You may select another location, or further customize the reporter's behavior with [the configuration options](https://allurereport.org/docs/mocha-configuration/). -## Usage +### View the report -Either add **allure-mocha** into **mocha.opts**: +> You need Allure Report to be installed on your machine to generate and open the report from the result files. See the [installation instructions](https://allurereport.org/docs/install/) on how to get it. -```text ---reporter allure-mocha +Generate Allure Report after the tests are executed: + +```bash +allure generate ./allure-results -o ./allure-report ``` -Or pass the same value via commandline / scripts: +Open the generated report: ```bash -mocha -R allure-mocha +allure open ./allure-report ``` -If you want to provide extra information, such as steps and attachments, import the `allure` object -into your code: +## Allure API -```javascript -const { epic } = require("allure-js-commons"); +Enhance the report by utilizing the runtime API: -it("is a test", async () => { - await epic("Some info"); -}); -``` +```js +import { describe, it } from "mocha"; +import * as allure from "allure-js-commons"; -### Parameters usage +describe("signing in with a password", () => { + it("should sign in with a valid password", async () => { + await allure.description("The test checks if an active user with a valid password can sign in to the app."); + await allure.epic("Signing in"); + await allure.feature("Sign in with a password"); + await allure.story("As an active user, I want to successfully sign in using a valid password"); + await allure.tags("signin", "ui", "positive"); + await allure.issue("https://github.com/allure-framework/allure-js/issues/1", "ISSUE-1"); + await allure.owner("eroshenkoam"); + await allure.parameter("browser", "chrome"); -```ts -const { parameter } = require("allure-js-commons"); + const user = await allure.step("Prepare the user", async () => { + return await createAnActiveUserInDb(); + }); -it("is a test", async () => { - await parameter("parameterName", "parameterValue"); -}); -``` + await allure.step("Make a sign-in attempt", async () => { + await allure.step("Navigate to the sign in page", async () => { + // ... + }); + + await allure.step("Fill the sign-in form", async (stepContext) => { + await stepContext.parameter("login", user.login); + await stepContext.parameter("password", user.password, "masked"); -The `parameter` method may also take the third argument with the `hidden` and `excluded` options: -`mode: "hidden" | "masked"` - `masked` replaces the value with `*` characters to secure sensitive data, and `hidden` hides the parameter from report. + // ... + }); -`excluded: true` - excludes the parameter from the history. + await allure.step("Submit the form", async () => { + // ... + // const responseData = ... -```ts -import { parameter } from "allure-js-commons"; + await allure.attachment("response", JSON.stringify(responseData), { contentType: "application/json" }); + }); + }); -it("is a test", async () => { - await parameter("parameterName", "parameterValue", { - mode: "hidden", - excluded: true, + await allure.step("Assert the signed-in state", async () => { + // ... + }); }); }); ``` -## Decorators Support - -To make tests more readable and avoid explicit API calls, you may use a special -extension - [ts-test-decorators](https://github.com/sskorol/ts-test-decorators). - -## Examples - -[mocha-allure-example](https://github.com/vovsemenv/mocha-allure-example) - a minimal setup for using -Mocha with Allure. +More details about the API are available at [https://allurereport.org/docs/mocha-reference/](https://allurereport.org/docs/mocha-reference/). diff --git a/packages/allure-playwright/README.md b/packages/allure-playwright/README.md index bfd8f23e3..a1bb06790 100644 --- a/packages/allure-playwright/README.md +++ b/packages/allure-playwright/README.md @@ -12,12 +12,18 @@ --- +## The documentation and examples + +The docs for Allure Playwright are available at [https://allurereport.org/docs/playwright/](https://allurereport.org/docs/playwright/). + +Also, check out the examples at [github.com/allure-examples](https://github.com/orgs/allure-examples/repositories?q=visibility%3Apublic+archived%3Afalse+topic%3Aexample+topic%3Aplaywright). + ## Installation -Use your favorite node package manager to install the package: +Install `allure-playwright` using a package manager of your choice. For example: -```bash -npm i -D allure-playwright +```shell +npm install -D allure-playwright ``` ## Usage @@ -49,82 +55,74 @@ npx playwright test --reporter=line,allure-playwright ``` When the test run completes, the result files will be generated in the `./allure-results` -directory. If you want to use another location, provide it via the `resultsDir` -reporter option ([see below](#allure-playwright-options)). +directory. + +You may select another location, or further customize the reporter's behavior with [the configuration options](https://allurereport.org/docs/playwright-configuration/). ### View the report -> [!NOTE] -> You need Allure Report to generate and open the report from the result files. See the [installation instructions](https://allurereport.org/docs/install/) for more details. +> You need Allure Report to be installed on your machine to generate and open the report from the result files. See the [installation instructions](https://allurereport.org/docs/install/) on how to get it. -Generate Allure Report: +Generate Allure Report after the tests are executed: ```bash allure generate ./allure-results -o ./allure-report ``` -Open Allure Report: +Open the generated report: ```bash allure open ./allure-report ``` -## The documentation - -Learn more about Allure Playwright from the official documentation at -[https://allurereport.org/docs/playwright/](https://allurereport.org/docs/playwright/). +## Allure API -## Allure Playwright options - -Use following options to configure Allure Playwright: - -| Option | Description | Default | -|-----------------|----------------------------------------------------------------------------------------------------------------------|--------------------| -| resultsDir | The path of the results folder. | `./allure-results` | -| detail | Hide the `pw:api` and `hooks` steps in report. | `true` | -| suiteTitle | Use test title instead of `allure.suite()`. | `true` | -| links | Allure Runtime API link templates. | `undefined` | -| environmentInfo | A set of key-value pairs to display in the Environment section of the report | `undefined` | -| categories | An array of category definitions, each describing a [category of defects](https://allurereport.org/docs/categories/) | `undefined` | - -Here is an example of the reporter configuration: +Enhance the report by utilizing the runtime API: ```js -import { defineConfig } from '@playwright/test'; -import os from "node:os"; - -export default defineConfig({ - reporter: [ - [ - "allure-playwright", - { - detail: true, - resultsDir: "my-allure-results", - suiteTitle: false, - links: { - link: { - urlTemplate: "https://github.com/allure-framework/allure-js/blob/main/%s", - }, - issue: { - urlTemplate: "https://github.com/allure-framework/allure-js/issues/%s", - nameTemplate: "ISSUE-%s", - }, - }, - environmentInfo: { - OS: os.platform(), - Architecture: os.arch(), - NodeVersion: process.version, - }, - categories: [ - { - name: "Missing file errors", - messageRegex: /^ENOENT: no such file or directory/, - }, - ], - }, - ], - ], +import { describe, test } from "playwright"; +import * as allure from "allure-js-commons"; + +describe("signing in with a password", () => { + test("sign in with a valid password", async () => { + await allure.description("The test checks if an active user with a valid password can sign in to the app."); + await allure.epic("Signing in"); + await allure.feature("Sign in with a password"); + await allure.story("As an active user, I want to successfully sign in using a valid password"); + await allure.tags("signin", "ui", "positive"); + await allure.issue("https://github.com/allure-framework/allure-js/issues/331", "ISSUE-331"); + await allure.owner("eroshenkoam"); + await allure.parameter("browser", "chrome"); + + const user = await allure.step("Prepare the user", async () => { + return await createAnActiveUserInDb(); + }); + + await allure.step("Make a sign-in attempt", async () => { + await allure.step("Navigate to the sign in page", async () => { + // ... + }); + + await allure.step("Fill the sign-in form", async (stepContext) => { + await stepContext.parameter("login", user.login); + await stepContext.parameter("password", user.password, "masked"); + + // ... + }); + + await allure.step("Submit the form", async () => { + // ... + // const responseData = ... + + await allure.attachment("response", JSON.stringify(responseData), { contentType: "application/json" }); + }); + }); + + await allure.step("Assert the signed-in state", async () => { + // ... + }); + }); }); ``` -More details about Allure Playwright configuration are available at [https://allurereport.org/docs/playwright-configuration/](https://allurereport.org/docs/playwright-configuration/). +More details about the API are available at [https://allurereport.org/docs/playwright-reference/](https://allurereport.org/docs/playwright-reference/). diff --git a/packages/allure-vitest/README.md b/packages/allure-vitest/README.md index fc4ab6016..18e6dfc9e 100644 --- a/packages/allure-vitest/README.md +++ b/packages/allure-vitest/README.md @@ -12,146 +12,113 @@ --- +## The documentation and examples + +The docs for Allure Vitest are available at [https://allurereport.org/docs/vitest/](https://allurereport.org/docs/vitest/). + +Also, check out the examples at [github.com/allure-examples](https://github.com/orgs/allure-examples/repositories?q=visibility%3Apublic+archived%3Afalse+topic%3Aexample+topic%3Avitest). + ## Installation -Use your favorite node package manager to install the package: +Install `allure-vitest` using a package manager of your choice. For example: -```bash -npm i -D allure-vitest +```shell +npm install -D allure-vitest ``` -## Configuration +> If you're a **Yarn PnP** user, you must also explicitly install `@vitest/runner` and `allure-js-commons`: +> ```shell +> yarn add --dev @vitest/runner allure-js-commons +> ``` +> Keep in mind, that `allure-js-commons` and `allure-vitest` must have the same version. The same goes for `vitest` and `@vitest/runner`. Use [`yarn info`](https://yarnpkg.com/cli/info) to check the versions. + +## Usage -Add instance of the reporter to the [`reporters` section](https://vitest.dev/config/#reporters) of your Vitest config: +Add `"allure-vitest/setup"` to `setupFiles` and `"allure-vitest/reporter"` to `reporters`: ```js import { defineConfig } from "vitest/config"; export default defineConfig({ test: { - // add setup file to be able to use Allure API via `global.allure` in your tests and to get test plan support setupFiles: ["allure-vitest/setup"], reporters: [ - // do not forget to keep the "default" if you want to see something in the console "default", - ["allure-vitest/reporter", { resultsDir: "./out/allure-results" }], + "allure-vitest/reporter", ], }, }); ``` -## Reporter options -Some reporter settings can set by following options: +When the test run completes, the result files will be generated in the `./allure-results` directory. -| Option | Description | Default | -| ---------- | ----------------------------------------------------- | ------------------ | -| resultsDir | Path to results folder | `./allure-results` | -| links | Links templates to make runtime methods calls simpler | `undefined` | +You may select another location, or further customize the reporter's behavior with [the configuration options](https://allurereport.org/docs/vitest-configuration/). -## Runtime API +### View the report -Use functions provided by `allure-js-commons` package to call Allure Runtime API methods: +> You need Allure Report to be installed on your machine to generate and open the report from the result files. See the [installation instructions](https://allurereport.org/docs/install/) on how to get it. -```js -import { test } from "vitest"; -import * as allure from "allure-js-commons"; +Generate Allure Report after the tests are executed: -test("sample test", async (context) => { - await allure.label(context, "foo", "bar"); - await allure.attachment("Attachment name", "Attachment content", "text/plain"); - await allure.step("my step", async () => { - await allure.step("another step", async () => { - await allure.label("foo", "bar"); - }); - }); -}); +```bash +allure generate ./allure-results -o ./allure-report ``` -## Links usage - -```js -import { it } from "vitest"; -import { link, issue } from "allure-js-commons"; +Open the generated report: -it("basic test", async () => { - await link("https://allurereport.org", "Allure Report"); // link with name - await issue("https://github.com/allure-framework/allure-js/issues/352", "Issue Name"); -}); +```bash +allure open ./allure-report ``` -You can also configure links formatters to make usage much more convenient. `%s` -in `urlTemplate` parameter will be replaced by given value. +## Allure API -```diff -import { defineConfig } from "vitest/config"; - -export default defineConfig({ - test: { - setupFiles: ["allure-vitest/setup"], - reporters: [ - "default", - ["allure-vitest/reporter", { - resultsDir: "./allure-results", -+ links: [ -+ { -+ type: "issue", -+ urlTemplate: "https://example.org/issues/%s", -+ nameTemplate: "Issue: %s", -+ }, -+ { -+ type: "tms", -+ urlTemplate: "https://example.org/tasks/%s" -+ }, -+ { -+ type: "custom", -+ urlTemplate: "https://example.org/custom/%s" -+ }, -+ ] - }], - ], - }, -}); -``` - -Then you can assign link using shorter notation: +Enhance the report by utilizing the runtime API: ```js -import { it } from "vitest"; -import { issue, tms, link } from "allure-js-commons"; - -it("basic test", async () => { - await issue("352", "Issue Name"); - await tms("352", "Task Name"); - await link("352", "Link name", "custom"); -}); -``` - -## Selective test execution +import { describe, it } from "vitest"; +import * as allure from "allure-js-commons"; -Allure allow you to execute only a subset of tests. This is useful when you want -to run only a specific test or a group of tests. +describe("signing in with a password", () => { + it("should sign in with a valid password", async () => { + await allure.description("The test checks if an active user with a valid password can sign in to the app."); + await allure.epic("Signing in"); + await allure.feature("Sign in with a password"); + await allure.story("As an active user, I want to successfully sign in using a valid password"); + await allure.tags("signin", "ui", "positive"); + await allure.issue("https://github.com/allure-framework/allure-js/issues/1", "ISSUE-1"); + await allure.owner("eroshenkoam"); + await allure.parameter("browser", "chrome"); + + const user = await allure.step("Prepare the user", async () => { + return await createAnActiveUserInDb(); + }); -It works out of the box if you add `allure-vitest/setup` to your `setupFiles` -config option. + await allure.step("Make a sign-in attempt", async () => { + await allure.step("Navigate to the sign in page", async () => { + // ... + }); -Allure will read `ALLURE_TESTPLAN_PATH` environment variable and read testplan -from the specified file. + await allure.step("Fill the sign-in form", async (stepContext) => { + await stepContext.parameter("login", user.login); + await stepContext.parameter("password", user.password, "masked"); -## Passing metadata from test title + // ... + }); -You also can pass allure metadata from test title. -This is useful when you need to set allureId for the tests with failing before hooks. Just add `@allure.id={idValue}` for the allureId or `@allure.label.{labelName}={labelValue}` for other types of labels. + await allure.step("Submit the form", async () => { + // ... + // const responseData = ... -```ts -import { test } from "vitest"; + await allure.attachment("response", JSON.stringify(responseData), { contentType: "application/json" }); + }); + }); -test("test with allureId @allure.id=256", () => {}); -test("tst with severity @allure.label.severity=critical", () => {}); -test("test with epic @allure.label.epic=login", () => {}); -test("test with strangeLabel @allure.label.strangeLabel=strangeValue", () => {}); + await allure.step("Assert the signed-in state", async () => { + // ... + }); + }); +}); ``` -> **Warning** -> Note that changing title can cause creating new testcases in history. -> To fix this please add `@allure.id={yourTestCaseId}` to the test name if you passing allure metadata from test title +More details about the API are available at [https://allurereport.org/docs/vitest-reference/](https://allurereport.org/docs/vitest-reference/). diff --git a/packages/newman-reporter-allure/README.md b/packages/newman-reporter-allure/README.md index 21d4c4ec5..7db58ec79 100644 --- a/packages/newman-reporter-allure/README.md +++ b/packages/newman-reporter-allure/README.md @@ -12,100 +12,67 @@ --- -## Installation - -```console -$ npm install -g newman-reporter-allure -``` - -## Usage - -To generate Allure results, specify `allure` in Newman's `-r` or `--reporters` option. +## The documentation and examples -```console -$ newman run -e -r allure -$ newman run -e -r allure --reporter-allure-resultsDir -``` - -Use the option `--reporter-allure-collection-as-parent-suite` to use the collection name as the parent suite title under the _Suites_ view. This helps when you run multiple collections and want to aggregate them in a single report. - -## Metadata +The docs for Allure Newman are available at [https://allurereport.org/docs/newman/](https://allurereport.org/docs/newman/). -You can add allure labels by passing javascript comments in the test field of postman request declaration +Also, check out the examples at [github.com/allure-examples](https://github.com/orgs/allure-examples/repositories?q=visibility%3Apublic+archived%3Afalse+topic%3Aexample+topic%3Anewman). -### Id +## Installation -```javascript -// @allure.id=228 +Install `newman-reporter-allure` using a package manager of your choice. For example: -pm.test("Status code is 200", function () { - pm.response.to.be.ok; -}); +```shell +npm install -D newman-reporter-allure ``` -### Label +## Usage -```javascript -// @allure.label.{{labelName}}={{labelValue}} +Enable the `allure` reporter via the CLI: -pm.test("Status code is 200", function () { - pm.response.to.be.ok; -}); +```shell +$ newman run "" -e "" -r allure ``` -### Story - -```javascript -// @allure.label.story=storyName +You may combine `allure` with other reporters: -pm.test("Status code is 200", function () { - pm.response.to.be.ok; -}); +```shell +$ newman run "" -e "" -r cli,allure ``` -### Suite +When the test run completes, the result files will be generated in the `./allure-results` directory. -```javascript -// @allure.label.suite=suiteName +You may select another location, or further customize the reporter's behavior with [the configuration options](https://allurereport.org/docs/newman-configuration/). -pm.test("Status code is 200", function () { - pm.response.to.be.ok; -}); -``` +### View the report -### Owner +> You need Allure Report to be installed on your machine to generate and open the report from the result files. See the [installation instructions](https://allurereport.org/docs/install/) on how to get it. -```javascript -// @allure.label.owner=ownerName +Generate Allure Report after the tests are executed: -pm.test("Status code is 200", function () { - pm.response.to.be.ok; -}); +```bash +allure generate ./allure-results -o ./allure-report ``` -### Tag +Open the generated report: -```javascript -// @allure.label.tag=tagName - -pm.test("Status code is 200", function () { - pm.response.to.be.ok; -}); +```bash +allure open ./allure-report ``` -## Generating and Serving Allure report - -Allure results will be generated under folder "allure-results" in the root location. -Use allure-commandline to serve the report locally. +## Allure API -```console -$ allure serve -``` - -Generate the static report web-application folder using allure-commandline +Enhance the report by utilizing the Allure API: -```console - $ allure generate --clean +```js +// @allure.label.epic:Authorization +// @allure.label.feature:BearerAuthorization +// @allure.label.story:ValidBearerToken +// @allure.label.tag:api +// @allure.label.owner:eroshenkoam +pm.test("Test Authentication", function () { + // ... +}); ``` -Report will be generated under folder "allure-report" in the root location. +More details about the API are available at [https://allurereport.org/docs/newman-reference/](https://allurereport.org/docs/newman-reference/).