New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

allure-cucumberjs

Package Overview
Dependencies
Maintainers
0
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

allure-cucumberjs - npm Package Compare versions

Comparing version 3.0.5 to 3.0.6

19

package.json
{
"name": "allure-cucumberjs",
"version": "3.0.5",
"version": "3.0.6",
"description": "Allure Cucumber.JS integration",
"keywords": [
"allure",
"cucumber",
"bdd",
"html",
"test",
"report",
"reporter",
"testing",
"testops"
],
"homepage": "https://allurereport.org/",

@@ -49,3 +60,3 @@ "repository": {

"dependencies": {
"allure-js-commons": "3.0.5"
"allure-js-commons": "3.0.6"
},

@@ -68,3 +79,3 @@ "devDependencies": {

"allure-commandline": "^2.29.0",
"allure-vitest": "3.0.5",
"allure-vitest": "3.0.6",
"babel-plugin-add-module-exports": "^1.0.4",

@@ -78,3 +89,3 @@ "eslint": "^8.57.0",

"eslint-plugin-prefer-arrow": "^1.2.3",
"npm-run-all2": "^6.1.2",
"npm-run-all2": "^7.0.0",
"rimraf": "^6.0.0",

@@ -81,0 +92,0 @@ "typescript": "^5.2.2",

@@ -15,215 +15,100 @@ # allure-cucumberjs

## Installation
## The documentation and examples
Install the required packages using your favorite package manager:
The docs for Allure Cucumber.js are available at
[https://allurereport.org/docs/cucumberjs/](https://allurereport.org/docs/cucumberjs/).
```shell
npm add -D allure-cucumberjs
```
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).
Create `reporter.js` with following content:
## Installation
```js
// reporter.js
const AllureCucumberReporter = require("allure-cucumberjs/reporter");
Install `allure-cucumberjs` using a package manager of your choice. For example:
export default AllureCucumberReporter;
```
Then add following lines to the CucumberJS configuration file:
```diff
// config.js
export default {
+ format: "./path/to/reporter.js",
};
```
And then run CLI with `config` parameter:
```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");
});
});
```
### View the report
### Using Allure Cucumber World
> 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.
If you prefer to use custom Allure World instead of global Allure API, you can use `AllureCucumberWorld` class:
Generate Allure Report after the tests are executed:
```js
import { AllureCucumberWorld } from "allure-cucumberjs";
import { setWorldConstructor } from "@cucumber/cucumber";
setWorldConstructor(AllureCucumberWorld);
```bash
allure generate ./allure-results -o ./allure-report
```
Then you'll be able to use Allure Runtime API through `this` in your step definition files:
Open the generated report:
```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");
});
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 open ./allure-report
```
If you run your Cucumber features using single thread mode, `AllureCucumberWorld` is set automatically.
## Allure API
### Links usage
Enhance the report by utilizing the Allure API:
```js
const { Given } = require("@cucumber/cucumber");
import { link, issue, tms } from "allure-js-commons";
import { When } from "@cucumber/cucumber";
import * as allure 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");
});
```
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");
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",
+ },
+ ],
+ }
};
```
Then you can assign link using shorter notation:
```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");
this.user = await createAnActiveUserInDb();
});
```
Links patterns also work with Cucumber tags which match `pattern` parameter:
When("they sign in with a valid password", async function () {
await allure.step("Navigate to the sign in page", async () => {
// ...
});
```gherkin
@issue=0
Feature: links
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");
@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");
// ...
});
});
```
Also addParameter takes an third optional parameter with the hidden and excluded options:
await allure.step("Submit the form", async () => {
// ...
// const responseData = ...
`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";
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/).
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc