![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
allure-cucumberjs
Advanced tools
Allure integration for
cucumber-js
compatible with@cucumber/cucumber@^8.x.x
and Allure 2+.
Install the required packages using your favorite package manager:
npm add -D allure-cucumberjs
Create reporter.js
with following content:
// reporter.js
const AllureCucumberReporter = require("allure-cucumberjs/reporter");
export default AllureCucumberReporter;
Then add following lines to the CucumberJS configuration file:
// config.js
export default {
+ format: "./path/to/reporter.js",
};
And then run CLI with config
parameter:
cucumber-js --config ./config.js
Some reporter settings can be set by following options:
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 |
To start using Allure Runtime API you need to add the following import into your ./feature/support/world.js
file:
import "allure-cucumberjs";
Then, you can call Allure Runtime API methods directly in your step definitions:
import { Given } from "@cucumber/cucumber";
import { label, attachment, step } from "allure-js-commons";
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");
});
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");
});
});
If you prefer to use custom Allure World instead of global Allure API, you can use AllureCucumberWorld
class:
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:
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");
});
});
If you run your Cucumber features using single thread mode, AllureCucumberWorld
is set automatically.
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");
});
You can also configure links formatters to make usage much more convenient. %s
in urlTemplate
parameter will be replaced by given value.
// 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:
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");
});
Links patterns also work with Cucumber tags which match pattern
parameter:
@issue=0
Feature: links
@issue=1 @tms=2
Scenario: a
Given a step
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:
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
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 });
});
});
For cross-browser testing simply add a parameter using Allure API with the browser name to the World
instance inside your scenario, i.e.:
import { parameter } from "allure-js-commons";
await parameter('Browser', 'firefox')
For better presentation, you can also group suites by browser names, i.e.:
import { parentSuite } from "allure-js-commons";
await parentSuite('Firefox')
FAQs
Allure Cucumber.JS integration
The npm package allure-cucumberjs receives a total of 32,821 weekly downloads. As such, allure-cucumberjs popularity was classified as popular.
We found that allure-cucumberjs demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.