allure-js icon indicating copy to clipboard operation
allure-js copied to clipboard

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

Open varshanharshank opened this issue 1 year ago • 4 comments

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

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

Screenshots N/A

Desktop (please complete the following information):

  • OS: [macbook pro, ventura 13.5 ]
  • Browser [chrome,edge,webkit]

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 avatar Jul 31 '23 17:07 varshanharshank