allure-framework / allure-js

Allure integrations for JavaScript test frameworks
https://allurereport.org/
Apache License 2.0
217 stars 112 forks source link

Playwright+BDD+Allure - How to print console.log and failure screenshot and recording in allure report #735

Open varshanharshank opened 11 months ago

varshanharshank commented 11 months ago

Describe the bug In the allure report, it is not printing console logs. Also need info about how to include screenshot for failure cases and recording.

To Reproduce Steps to reproduce the behavior: 1.Create Playwright with BDD project

  1. In cucumber.json file, just mention the allureReport.ts file path
  2. Run the following command npx cucumber-js test --tags '@smoke
  3. Run the following command for generate allure report npx allure generate allure-results --clean -o allure-report && npx allure open allure-report
  4. Observe the report

Expected behavior Console.log should be printed in the report.

Screenshots N/A

Desktop (please complete the following information):

Additional context used the below json //package.json { "name": "automation", "version": "1.0.0", "description": "Automation", "main": "index.js", "scripts": { "test": "node_modules/.bin/cucumber-js test --tags '@smoke'", "report": "npx ts-node src/helper/report/cucumberReport.ts", "allure": "npx allure generate allure-results --clean -o allure-report && ./node_modules/.bin/allure open allure-report", "lint": "node_modules/.bin/eslint . --ext .ts" }, "author": "", "license": "ISC", "dependencies": { "@cucumber/cucumber": "^9.3.0" }, "devDependencies": { "@playwright/test": "^1.36.2", "@typescript-eslint/eslint-plugin": "^6.2.0", "@typescript-eslint/parser": "^6.2.0", "allure-commandline": "^2.23.1", "allure-cucumberjs": "^2.4.0", "allure-js-commons": "^2.4.0", "eslint": "^8.46.0", "moment": "^2.29.4", "multiple-cucumber-html-reporter": "^3.4.0", "prettier": "^3.0.0", "ts-node": "^10.9.1", "typescript": "^5.1.6" } }

//cucumber.json { "default": { "paths": ["src/test/features"], "require": ["src/test/stepDefinitions/*.ts", "src/hooks/hooks.ts"], "requireModule": ["ts-node/register"], "publishQuiet": true, "format": [ "./src/helper/report/allureReport.ts" ] } }

//allureReport.ts

import { AllureRuntime, CucumberJSAllureFormatter } from 'allure-cucumberjs'

function Reporter(options: any) { return new CucumberJSAllureFormatter( options, new AllureRuntime({ resultsDir: './allure-results' }), { labels: [ { name: 'epic', pattern: [/@feature:(.)/], }, { name: 'severity', pattern: [/@severity:(.)/], }, ], links: [ { type: 'issue', pattern: [/@issue=(.)/], urlTemplate: 'http://localhost:8080/issue/%s', }, { type: 'tms', pattern: [/@tms=(.)/], urlTemplate: 'http://localhost:8080/tms/%s', }, ], } ) }

Reporter.prototype = Object.create(CucumberJSAllureFormatter.prototype) Reporter.prototype.constructor = Reporter

exports.default = Reporter

varshanharshank commented 5 months ago

any update

mayank2708 commented 4 months ago

I am also facing same issue

varshanharshank commented 3 months ago

@epszaw do you have any update about this?