allure-framework / allure-js

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

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

Open varshanharshank opened 1 year ago

varshanharshank commented 1 year 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 9 months ago

any update

mayank2708 commented 9 months ago

I am also facing same issue

varshanharshank commented 8 months ago

@epszaw do you have any update about this?

samixchoumi commented 1 month ago

Hello @baev, do you know if this issue can make screenshot appear using playwright-bdd framework too ? Because actually I don't see any screenshot while I generate failing screenshot in my config See :

reporter: [
    [
      './node_modules/playwright-slack-report/dist/src/SlackReporter.js',
      { sendResults: 'off' }
    ],
    ['blob'],
    ['list'],
    ['allure-playwright', { outputFolder: `allure-results` }]
  ],
use: {
    baseURL: config.baseUrl,
    trace: 'off',
    screenshot: 'only-on-failure'
  },

Here is my package.json dependencies :

"devDependencies": {
    "@faker-js/faker": "^9.0.3",
    "@playwright/test": "^1.47.2",
    "@types/node": "^22.7.4",
    "allure-playwright": "^3.0.5",
    "dotenv": "^16.4.5",
    "fs-extra": "^11.2.0",
    "moment": "^2.30.1",
    "playwright-bdd": "^7.4.2",
    "playwright-slack-report": "^1.1.88",
    "reflect-metadata": "^0.2.2",
    "ts-node": "^10.9.2"
  }

It seem to works fine without using Cucumber, but still, I don't seem to override this behavior and it could be very nice to have failing screenshot