allure-framework / allure-framework/allure-js

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

Open
#735 4 comments 0 reactions 0 assignees View on GitHub
theme:cucumberjs
Dominant language
TypeScript
Stars
281
Forks
137
Avg merge
1d 11h
Merged PRs (30d)
13

Description

**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

Contributor guide

Open the contributing guide

Research direction

Start with src/helper/report/allureReport.ts and cucumber.json, then run the reported cucumber-js smoke command and generate the report with the supplied Allure commands. Check how the formatter handles console output and failure artifacts from the Playwright/Cucumber setup; done means the expected console logs, screenshots, and recordings are visible in the Allure report.

Written by the indexing model from the issue text.

Assessment

Tech stack
playwright, typescript
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.