badeball / cypress-cucumber-preprocessor

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

Error while running scripts #1231

Closed vj160921 closed 1 month ago

vj160921 commented 1 month ago

cy.task('cypress-cucumber-preprocessor:append-messages') failed with the following error: The task 'cypress-cucumber-preprocessor:append-messages' was not handled in the setupNodeEvents method. The following tasks are registered: cypress-cucumber-preprocessor:spec-envelopes, cypress-cucumber-preprocessor:test-case-started, cypress-cucumber-preprocessor:test-step-started, cypress-cucumber-preprocessor:test-step-finished, cypress-cucumber-preprocessor:test-case-finished, cypress-cucumber-preprocessor:create-string-attachment Fix this in your setupNodeEvents method here: cypress.config.ts Because this error occurred during a after all hook we are skipping all of the remaining tests.

This is my config file and I am not sure what is causing the issue:

import { defineConfig } from "cypress"; import * as createBundler from "@bahmutov/cypress-esbuild-preprocessor"; import { addCucumberPreprocessorPlugin } from "@badeball/cypress-cucumber-preprocessor"; import createEsbuildPlugin from "@badeball/cypress-cucumber-preprocessor/esbuild"; const cypressOnFix = require('cypress-on-fix'); const { beforeRunHook } = require('cypress-mochawesome-reporter/lib');

export default defineConfig({ e2e: { specPattern: 'cypress/e2e/*/.feature', async setupNodeEvents(on, config) { on = cypressOnFix(on); on('before:run', async (details) => { await beforeRunHook(details); }); await addCucumberPreprocessorPlugin(on, config); on( 'file:preprocessor', createBundler({ plugins: [createEsbuildPlugin(config)], }) ); return config; }, }, });

Also getting this error: cy.task('cypress-cucumber-preprocessor:spec-envelopes') failed with the following error: > Unexpected state in specEnvelopesHandler: uninitialized. This almost always means that you or some other plugin, are overwriting this plugin's event handlers. For more information & workarounds, see https://github.com/badeball/cypress-cucumber-preprocessor/blob/master/docs/event-handlers.md (if neither workaround work, please report at https://github.com/badeball/cypress-cucumber-preprocessor) Because this error occurred during a before all hook we are skipping the remaining tests in the current suite.

Can anyone please let me know what could be the reason for the above issue and do I need to update anything in cypress.config.ts. I have tried all the workarounds

Versions

Checklist

badeball commented 1 month ago

First of all, the checklist isn't voluntary. I expect you to search for solutions by yourself.

Secondly, this is most likely a caching issue, as the mentioned task (spec-envelopes) was removed a long time ago. You can confirm this by trying on a different machine.

vj160921 commented 1 month ago

@badeball I have tried workarounds mentioned in the cypress error. I have also tried clearing cache but it did not help resolve the issue.

badeball commented 1 month ago

Dude, you’re being wildly unhelpful here. Did you try on a different computer? This might confirm that this is in fact a caching issue.

vj160921 commented 1 month ago

I have tried this in another system but I am not getting this issue in a different computer.

badeball commented 1 month ago

Well that explains the problem. I, as a plugin author, have no control nor knowledge over Cypress’ caching locations. You have to direct your attention elsewhere.