Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 475 introduce new cucumber allure world #491

Merged
merged 40 commits into from
Nov 23, 2022

Conversation

epszaw
Copy link
Member

@epszaw epszaw commented Sep 1, 2022

fixes #475

Context

Changes the logic for work with nested steps and their labels and attachments introducing our own enhanced World implementation.

Example:

const { Then, setWorldConstructor } = require('@cucumber/cucumber')

Then("test name", async function () {
  // use anonymous function
  await this.step("nested step one", function() {
     // any label attaches to the current cucumber step, not nested one
     this.label("label_name", "label_value");
     this.epic("epic_name");
     // the attachment will be attached to the nested step
     this.attachment(JSON.stringify({ foo: 'bar' }), 'application/json')
  })

  // or arrow one
  await this.step("nested step one", (step) => {
     // any label attaches to the current cucumber step, not nested one
     step.label("label_name", "label_value");
     step.epic("epic_name");
     // the attachment will be attached to the nested step
     step.attachment(JSON.stringify({ foo: 'bar' }), 'application/json')
  })
})

If you want to keep the functoinality in parallel mode, set CucumberAllureWorld as world constructor:

- const { Then } = require('@cucumber/cucumber')
+ const { Then, setWorldConstructor } = require('@cucumber/cucumber')
+ const { CucumberAllureWorld } = require("allure-cucumberjs")

+ // after that you're able to use `this.label`, `this.step` etc. methods inside your steps defs
+ setWorldConstructor(CucumberAllureWorld);

Then("test name", async function () {
  // use anonymous function
  await this.step("nested step one", function() {
     // any label attaches to the current cucumber step, not nested one
     this.label("label_name", "label_value");
     this.epic("epic_name");
     // the attachment will be attached to the nested step
     this.attachment(JSON.stringify({ foo: 'bar' }), 'application/json')
  })

  // or arrow one
  await this.step("nested step one", (step) => {
     // any label attaches to the current cucumber step, not nested one
     step.label("label_name", "label_value");
     step.epic("epic_name");
     // the attachment will be attached to the nested step
     step.attachment(JSON.stringify({ foo: 'bar' }), 'application/json')
  })
})

Checklist

@epszaw epszaw added type:bug Something isn't working theme:cucumberjs CucumberJS related issue labels Sep 1, 2022
@github-actions github-actions bot added theme:api Javascript API related issue theme:playwright labels Sep 1, 2022
@epszaw epszaw marked this pull request as ready for review September 2, 2022 15:51
@epszaw epszaw requested a review from baev September 2, 2022 15:51
@epszaw epszaw changed the title Issue 475 cucumber executable Issue 475 introduce new cucumber allure world Sep 5, 2022
@epszaw epszaw force-pushed the issue-475-cucumber-executable branch from 38d281f to b7d55b0 Compare October 18, 2022 10:30
@epszaw epszaw force-pushed the issue-475-cucumber-executable branch from f4d58d5 to fe04729 Compare November 17, 2022 11:37
@@ -0,0 +1,329 @@
import process from "node:process";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please clenup unused imports

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Collaborator

@vovsemenv vovsemenv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good overall.
⚠️ Tested with https://stackblitz.com/edit/node-xnc6mn?file=package.json
allure-results generated successfully in paralell mode but report something goes wrong with attachments
image

⚠️ Also something wrong with typescript. It didn't get types for our allure utilities
image

Copy link
Collaborator

@vovsemenv vovsemenv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks fine.
Report in parallel mode works fine in example tests. (I imagine if we have big cucumber project to test on)
Some changes to readme and we fine to go.

packages/allure-cucumberjs/README.md Outdated Show resolved Hide resolved
packages/allure-cucumberjs/README.md Outdated Show resolved Hide resolved
packages/allure-cucumberjs/README.md Outdated Show resolved Hide resolved
packages/allure-cucumberjs/README.md Outdated Show resolved Hide resolved
packages/allure-cucumberjs/README.md Outdated Show resolved Hide resolved
packages/allure-cucumberjs/README.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@vovsemenv vovsemenv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👻 LGTM
Tested locally

@baev baev merged commit 9bfd2c9 into master Nov 23, 2022
@baev baev deleted the issue-475-cucumber-executable branch November 23, 2022 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme:api Javascript API related issue theme:cucumberjs CucumberJS related issue theme:playwright type:bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[allure-js] Cannot start new step using v.2.0.0-beta.18 with cucumber-js
3 participants