3

I'm trying to implement the Allure reports in Playwright with Cucumber. I'm running the features in the next way:

npm run test -- --tags "@Something"

After an execution I type: npm run allure generate but the browser displays an Allure Report Unknown NaN%

This is my package.json file:

{
  "name": "playwright",
  "version": "1.0.0",
  "description": "E2E Automation Framework",
  "main": "index.js",
  "type": "module",
  "scripts": {
    "allure:generate": "npx allure generate ./allure-results --clean",
    "allure:open": "npx allure open ./allure-report",
    "allure:serve": "npx allure serve",
    "test": "./node_modules/.bin/cucumber-js --require cucumber.cjs --require step-definitions/**/*.cjs --require features/**/*.js",
    "allure-reports": "node_modules/.bin/allure generate ./reports/allure/allure-results/  -o ./reports/allure/allure-report/ --clean && allure open ./reports/allure/allure-report",
    "posttest": "npm run allure:generate",
    "allure": "allure serve reports/allure-results"
  },
  "author": "X",
  "license": "ISC",
  "dependencies": {
    "@cucumber/cucumber": "^8.7.0",
    "chai": "^4.3.6",
    "prettier": "^2.7.1",
    "ts-jest": "^29.0.3"
  },
  "jest": {
    "verbose": true,
    "moduleDirectories": [
      "node_modules",
      "src"
    ],
    "preset": "ts-jest/presets/js-with-ts",
    "testEnvironment": "node",
    "allowJs": true,
    "transform": {
      "^.+\\.jsx?$": "babel-jest"
    },
    "transformIgnorePatterns": [
      "<rootDir>/node_modules/(?!variables/.*)"
    ]
  },
  "devDependencies": {
    "@babel/core": "^7.19.6",
    "@babel/preset-env": "^7.19.4",
    "@babel/register": "^7.18.9",
    "@jest/globals": "^29.3.0",
    "@playwright/test": "^1.27.1",
    "@testing-library/jest-dom": "^5.16.5",
    "@testing-library/react": "^13.4.0",
    "allure-commandline": "^2.18.1",
    "allure-playwright": "^2.0.0-beta.19",
    "babel-jest": "^29.2.2",
    "experimental-allure-playwright": "^0.0.3",
    "identity-obj-proxy": "^3.0.0",
    "jest": "^29.2.2",
    "playwright": "^1.27.1",
    "react-test-renderer": "^18.2.0"
  }
}

If anybody could help me with this? Thanks in advance.

nosequeweaponer
  • 511
  • 10
  • 38

2 Answers2

2

What I discover is that you are executing the test cases with "test": "./node_modules/.bin/cucumber-js. That means that the configuration should be under your cucumber.js

// cucumber.js
let options = [
  '--require-module ts-node/register', // Load Typescript module
  '--require ./steps/**.ts', // Load steps
  '--format progress', // Load custom formatter
  '--format json:reports/cucumber_report.json', // JSON report
  '--format html:reports/cucumber-report.html',
  //'--format ./reporter.ts', // Allure report
  '--publish-quiet',
  '--tags @mytag',
  '--parallel 2',
  '--retry 0',
].join(' ')

let run_features = [
  './features/', // Specify our feature files location
  options,
].join(' ')

module.exports = {
  test_runner: run_features,
  parallel: 2,
}

As you can see there is a commented line for allure. When we uncomment this line the reporter.js is going to be the report format, in my case I copied from here

And my scripts at the package.json are:

  "scripts": {
        "test": "cucumber-js -p test_runner",
        "allure:generate": "npx allure generate ./allure-results --clean",
        "allure:open": "allure open allure-report",
        "all": "npm test && npm run allure:generate && npm run allure:open"
  },
j.barrio
  • 1,006
  • 1
  • 13
  • 37
0

I have something setup as below in package.json for Playwright-jest-allure.

{
  "name": "playwright",
  "version": "1.0.0",
  "description": "Sab Playwright",
  "main": "index.js",
  "author": "Sab",
  "license": "MIT",
  "dependencies": {
    "jest": "^27.5.1",
    "jest-playwright-preset": "^1.7.0",
    "playwright": "^1.20.2"
  },
  "scripts": {
    "test": "jest"
  },
  "devDependencies": {
    "jasmine-allure-reporter": "^1.0.2",
    "jest-allure": "^0.1.3",
    "jasmine":"^3.7.0",
    "@wdio/allure-reporter": "^7.16.14",
    "@wdio/cli": "^7.5.2",
    "allure-commandline": "^2.17.2"

  }
}

Below is the allure-results and allure-report , latter gets generated once run is successful and command - npx allure generate ./allure-results --clean

enter image description here

allure-results please make sure xmls' are generated here for the tests run

Allure report:

enter image description here

With cucumberjs, nothing much different other than hooks,cucumber config file. Still if you are facing issue, let me know. I can post the setup I have made on it.

Sab
  • 69
  • 3