badeball / cypress-cucumber-preprocessor

Run cucumber/gherkin-syntaxed specs with Cypress
MIT License
1.32k stars 147 forks source link

When I start to run test cases, I am getting error , Integratied Allure Report and #1079

Closed nurullahsahin44 closed 1 year ago

nurullahsahin44 commented 1 year ago

Current behavior

CypressError: cy.task('cypress-cucumber-preprocessor:spec-envelopes') failed with the following error:

Unexpected state in specEnvelopesHandler: initial (this might be a bug, please report at https://github.com/badeball/cypress-cucumber-preprocessor)

https://on.cypress.io/api/task

Because this error occurred during a null hook we are skipping the remaining tests in the current suite: Test Login

Desired behavior

Don't want to get any error and Allure report

Test code to reproduce

Versions

"@badeball/cypress-cucumber-preprocessor": "^18.0.4",
"@bahmutov/cypress-esbuild-preprocessor": "^2.2.0",
"@cypress/browserify-preprocessor": "^3.0.2",
"@cypress/webpack-preprocessor": "^5.17.1",
"@shelex/cypress-allure-plugin": "^2.40.0",
"allure-commandline": "2.23.1",
"cucumber": "^6.0.7",
"cypress": "^12.17.4",
"cypress-xpath": "^2.0.1",
"esbuild": "^0.17.19",
"eslint-plugin-cypress": "^2.13.3",
"mocha-allure-reporter": "^1.4.0",
"typescript": "^5.1.6"

node = 18.16.1

Checklist

cypress.config.js file

const { defineConfig } = require("cypress"); const createBundler = require("@bahmutov/cypress-esbuild-preprocessor"); const addCucumberPreprocessorPlugin = require("@badeball/cypress-cucumber-preprocessor").addCucumberPreprocessorPlugin; const createEsbuildPlugin = require("@badeball/cypress-cucumber-preprocessor/esbuild").createEsbuildPlugin;

const allureWriter = require('@shelex/cypress-allure-plugin/writer'); module.exports = defineConfig({ e2e: { setupNodeEvents(on, config) { const bundler = createBundler({ plugins: [createEsbuildPlugin(config)], });

    on("file:preprocessor", bundler);
    addCucumberPreprocessorPlugin(on, config);
      allureWriter(on, config);
      return config;
  },
  specPattern: "cypress\\e2e\\*.feature", 
  chromeWebSecurity: false,

},

});

badeball commented 1 year ago

The checklist isn’t optional but serve a purpose.

nurullahsahin44 commented 1 year ago

Sorry for checklist,I couldn't pay attention, actually I tried so much times and I checked so much projects, but i could not resolve the problem, I using @badeball/cypress-cucumber-preprocessor 18.0.4 and everythink is ok, when I add to AllureReport as meen allureWriter function, it is not working , When I using the below configuration.json actually test is running but allure report was not create, when create the allure report test cases could not run. :(

const { defineConfig } = require("cypress"); const { addCucumberPreprocessorPlugin } = require("@badeball/cypress-cucumber-preprocessor"); const createBundler = require("@bahmutov/cypress-esbuild-preprocessor"); const { createEsbuildPlugin } = require("@badeball/cypress-cucumber-preprocessor/esbuild"); const allureWriter = require('@shelex/cypress-allure-plugin/writer'); module.exports = defineConfig({ chromeWebSecurity: false, e2e: { specPattern: "*/.feature", async setupNodeEvents(on, config) { allureWriter(on, config); // implement node event listeners here on("file:preprocessor", createBundler({ plugins: [createEsbuildPlugin(config)], }));

  await addCucumberPreprocessorPlugin(on, config);
  return config;
},
env: {
  allureReuseAfterSpec: true
}

}, });

badeball commented 1 year ago

What points on the checklist have you gone through?

nurullahsahin44 commented 1 year ago
badeball commented 1 year ago

That's not the checklist I'm referring to. What checklist did the issue template comprise of?

nurullahsahin44 commented 1 year ago

cypress.config.js

badeball commented 1 year ago

That’s not at all the right answer. The issue template can be seen when opening a new issue or otherwise here: https://github.com/badeball/cypress-cucumber-preprocessor/blob/master/.github/ISSUE_TEMPLATE.md

nurullahsahin44 commented 1 year ago

I checked all of list. I have read, Also using v18.0.4 , I want to remind again,

When I using to below configuration, test running but allure report could not occur, I wrote to allure report side for this problem,

const { defineConfig } = require("cypress"); const { addCucumberPreprocessorPlugin } = require("@badeball/cypress-cucumber-preprocessor"); const createBundler = require("@bahmutov/cypress-esbuild-preprocessor"); const { createEsbuildPlugin } = require("@badeball/cypress-cucumber-preprocessor/esbuild"); const allureWriter = require('@shelex/cypress-allure-plugin/writer');

module.exports = defineConfig({ chromeWebSecurity: false, e2e: { specPattern: "*/.feature", async setupNodeEvents(on, config) { allureWriter(on, config); // implement node event listeners here on("file:preprocessor", createBundler({ plugins: [createEsbuildPlugin(config)], }));

  await addCucumberPreprocessorPlugin(on, config);
  return config;
},
env: {
  allureReuseAfterSpec: true
}

}, });

**When I using to below configuration, test not running but allure-result created *** also added test results

const { defineConfig } = require("cypress"); const createBundler = require("@bahmutov/cypress-esbuild-preprocessor"); const addCucumberPreprocessorPlugin = require("@badeball/cypress-cucumber-preprocessor").addCucumberPreprocessorPlugin; const createEsbuildPlugin = require("@badeball/cypress-cucumber-preprocessor/esbuild").createEsbuildPlugin;

const allureWriter = require('@shelex/cypress-allure-plugin/writer'); module.exports = defineConfig({ e2e: { setupNodeEvents(on, config) { const bundler = createBundler({ plugins: [createEsbuildPlugin(config)], });

  on("file:preprocessor", bundler);
  addCucumberPreprocessorPlugin(on, config);
  allureWriter(on, config);
  return config;
},
specPattern: "cypress/e2e/*.feature",
chromeWebSecurity: false,

},

});

and fail results

CypressError: cy.task('cypress-cucumber-preprocessor:spec-envelopes') failed with the following error:

Unexpected state in specEnvelopesHandler: initial (this might be a bug, please report at https://github.com/badeball/cypress-cucumber-preprocessor)

https://on.cypress.io/api/task

Because this error occurred during a null hook we are skipping the remaining tests in the current suite: Test Login at (http://localhost:49623/__cypress/runner/cypress_runner.js:134597:70) at tryCatcher (http://localhost:49623/__cypress/runner/cypress_runner.js:1807:23) at Promise._settlePromiseFromHandler (http://localhost:49623/__cypress/runner/cypress_runner.js:1519:31) at Promise._settlePromise (http://localhost:49623/__cypress/runner/cypress_runner.js:1576:18) at Promise._settlePromise0 (http://localhost:49623/__cypress/runner/cypress_runner.js:1621:10) at Promise._settlePromises (http://localhost:49623/__cypress/runner/cypress_runner.js:1697:18) at _drainQueueStep (http://localhost:49623/__cypress/runner/cypress_runner.js:2407:12) at _drainQueue (http://localhost:49623/__cypress/runner/cypress_runner.js:2400:9) at Async._drainQueues (http://localhost:49623/__cypress/runner/cypress_runner.js:2416:5) at Async.drainQueues (http://localhost:49623/__cypress/runner/cypress_runner.js:2286:14) From Your Spec Code: at taskSpecEnvelopes (http://localhost:49623/__cypress/tests?p=cypress/e2e/login.feature:14016:14) at Context.beforeHandler (http://localhost:49623/__cypress/tests?p=cypress/e2e/login.feature:14394:9) at Context.eval (http://localhost:49623/__cypress/tests?p=cypress/e2e/login.feature:14077:27)

From Node.js Internals: Error: Unexpected state in specEnvelopesHandler: initial (this might be a bug, please report at https://github.com/badeball/cypress-cucumber-preprocessor) at createError (/Users/nurullah.sahin/Desktop/Automation Projects/iyzipay-checkout-automation/node_modules/@badeball/cypress-cucumber-preprocessor/dist/helpers/error.js:9:12) at specEnvelopesHandler (/Users/nurullah.sahin/Desktop/Automation Projects/iyzipay-checkout-automation/node_modules/@badeball/cypress-cucumber-preprocessor/dist/plugin-event-handlers.js:300:43) at invoke (/Users/nurullah.sahin/Library/Caches/Cypress/12.17.4/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:246:16) at (/Users/nurullah.sahin/Library/Caches/Cypress/12.17.4/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:59:14) at tryCatcher (/Users/nurullah.sahin/Library/Caches/Cypress/12.17.4/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/util.js:16:23) at Function.Promise.attempt.Promise.try (/Users/nurullah.sahin/Library/Caches/Cypress/12.17.4/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/method.js:39:29) at Object.wrapChildPromise (/Users/nurullah.sahin/Library/Caches/Cypress/12.17.4/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:58:23) at RunPlugins.taskExecute (/Users/nurullah.sahin/Library/Caches/Cypress/12.17.4/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:252:10) at RunPlugins.execute (/Users/nurullah.sahin/Library/Caches/Cypress/12.17.4/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:166:21) at EventEmitter. (/Users/nurullah.sahin/Library/Caches/Cypress/12.17.4/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:56:12) at EventEmitter.emit (node:events:513:28) at EventEmitter.emit (node:domain:489:12) at process. (/Users/nurullah.sahin/Library/Caches/Cypress/12.17.4/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:33:22) at process.emit (node:events:513:28) at process.emit (node:domain:489:12) at process.emit.sharedData.processEmitHook.installedValue [as emit] (/Users/nurullah.sahin/Library/Caches/Cypress/12.17.4/Cypress.app/Contents/Resources/app/node_modules/@cspotcode/source-map-support/source-map-support.js:745:40) at emit (node:internal/child_process:937:14) at processTicksAndRejections (node:internal/process/task_queues:83:21)

badeball commented 1 year ago

Did you read the FAQ though? And thoroughly?

badeball commented 1 year ago

Closing as not my problem. You need to figure out this stuff yourself.