Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Json report is not generated with Allure Writer and Cucumber Preprocessor plugin enabled #150

Closed
elena-altuhova opened this issue Aug 15, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@elena-altuhova
Copy link

When my automation is finished and I expect Json to be generated with active Allure Writer - createPickle() function returns an error.

Console error

{ function: 'createPickle', fileUrl: 'hostname/__cypress/tests?p=cypress\\features\\connectivity\\FacebookAds.feature', originalFile: 'node_modules/@badeball/cypress-cucumber-preprocessor/lib/create-tests.js', relativeFile: 'node_modules/@badeball/cypress-cucumber-preprocessor/lib/create-tests.js', absoluteFile: 'C:\\Users\\user\\IdeaProjects\\ui-functional/node_modules/@badeball/cypress-cucumber-preprocessor/lib/create-tests.js', line: 240, column: 1, whitespace: ' ', stack: 'Error\n' + ' at createPickle (hostname/__cypress/tests?p=cypress\\features\\connectivity\\FacebookAds.feature:6660:5)\n' + ' at createScenario (hostname/__cypress/tests?p=cypress\\features\\connectivity\\FacebookAds.feature:6577:9)\n' + ' at Suite.eval (hostname/__cypress/tests?p=cypress\\features\\connectivity\\FacebookAds.feature:6500:21)\n' + ' at createFeature (hostname/__cypress/tests?p=cypress\\features\\connectivity\\FacebookAds.feature:6496:5)\n' + ' at createTests (hostname/__cypress/tests?p=cypress\\features\\connectivity\\FacebookAds.feature:6876:9)\n' + ' at 1.C:/Users/user/IdeaProjects/ui-functional/cypress/stepdefs/addAuthorizationSteps.js (hostname/__cypress/tests?p=cypress\\features\\connectivity\\FacebookAds.feature:23:5)\n' + ' at o (hostname/__cypress/tests?p=cypress\\features\\connectivity\\FacebookAds.feature:1:265)\n' + ' at r (hostname/__cypress/tests?p=cypress\\features\\connectivity\\FacebookAds.feature:1:431)\n' + ' at eval (hostname/__cypress/tests?p=cypress\\features\\connectivity\\FacebookAds.feature:1:460)\n' + ' at eval (<anonymous>)' }

Test code to reproduce

Run any cucumber scenario with below cypress.config.js and package.json

cypress.config.js

const {defineConfig} = require('cypress')
const preprocessor = require("@badeball/cypress-cucumber-preprocessor");
const browserify = require("@badeball/cypress-cucumber-preprocessor/browserify");
const allureWriter = require("@shelex/cypress-allure-plugin/writer");

async function setupNodeEvents(on, config) {
    await preprocessor.addCucumberPreprocessorPlugin(on, config);

    on("file:preprocessor", browserify.default(config));

    allureWriter(on, config);
    
    return config
}


module.exports = defineConfig({
    projectId: 'cypress-e2e',
    downloadsFolder: 'downloads',
    env: {
        username: 'atf_user'
    },
    video: false,
    watchForFileChanges: false,
    reporter: 'junit',
    chromeWebSecurity: false,
    reporterOptions: {
        mochaFile: 'results/cypress-report-[hash].xml',
        toConsole: true,
    },
    numTestsKeptInMemory: 0,
    e2e: {
        baseUrl: 'hostname',
        specPattern: 'cypress/features/**/*.{feature,features}',
        setupNodeEvents
    },
})

package.json

{
  "name": "ui-functional",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "devDependencies": {
    "@badeball/cypress-cucumber-preprocessor": "^12.0.1",
    "@cypress/browserify-preprocessor": "^3.0.2",
    "@shelex/cypress-allure-plugin": "^2.28.4",
    "cucumber-json-merge": "^0.0.8",
    "cypress": "^10.3.1",
    "cypress-wait-until": "^1.7.2",
    "cypress-xpath": "^1.6.2"
  },
  "dependencies": {
    "cy2": "^2.0.0",
    "lodash": "^4.17.21"
  },
  "cypress-cucumber-preprocessor": {
    "stepDefinitions": "cypress/stepdefs/*.{js,ts}",
    "filterSpecs": true,
    "omitFiltered": true,
    "json": {
      "enabled": true,
      "output": "cypress/cucumber-json/cucumber-json.json",
      "formatter": "cucumber-json-formatter"
    },
    "messages": {
      "enabled": true,
      "output": "cypress/cucumber-json/messages.ndjson"
    }
  }
}

Versions

Cypress version: 10.3.1
Preprocessor version: 12.0.1
Allure plugin version: 2.28.4
Node version: 17.9.0

Additional context

Issue was initially opened in cucumber preprocessor repo, but as per owner's suggestion reopening it here. Please take a look at the last comment: badeball/cypress-cucumber-preprocessor#797

@elena-altuhova elena-altuhova added the bug Something isn't working label Aug 15, 2022
@Shelex
Copy link
Owner

Shelex commented Sep 4, 2022

Hi @elena-altuhova

Since v2.30.2 you can pass env variable allureReuseAfterSpec: true and it will not register new listener thus resolve your case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants