badeball / cypress-cucumber-preprocessor

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

Expected there to be a timestamp for current step #1206

Closed topesho closed 1 day ago

topesho commented 1 week ago

Hi @badeball I am having this issue with when you run the command -e.g. npm run test or npx cypress run -e TAGS='@home' --headed .

The test only runs from the Cypress dashboard with npx cypress open.

CypressError: cy.task('cypress-cucumber-preprocessor:test-case-started') failed with the following error:

state.messages.current.findLastIndex is not a function

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

Error: Expected there to be a timestamp for current step (this might be a bug, please report at https://github.com/badeball/cypress-cucumber-preprocessor)

Because this error occurred during a after each hook we are skipping the remaining tests in the current suite:

An error was thrown in your plugins file while executing the handler for the after:spec event.

The error we received was:

image

node version 17.5.0

I am using the following package.json.

{ "name": "xx", "version": "1.0.0", "description": "xx", "main": "index.js", "scripts": { "remove-cucumber-json-formatter": "rm -f tools/cucumber-json-formatter", "download-cucumber-json-formatter": "curl -L https://github.com/cucumber/cucumber-json-formatter/releases/download/vX.Y.Z/cucumber-json-formatter-linux-amd64 -o tools/cucumber-json-formatter && chmod +x tools/cucumber-json-formatter", "full_regression": "npm run download-cucumber-json-formatter && npx cypress run -e TAGS='@home' --headed && node cucumber-html-report.js; npm run remove-cucumber-json-formatter" }, "author": "", "license": "ISC", "devDependencies": { "@badeball/cypress-cucumber-preprocessor": "^20.1.0", "@bahmutov/cypress-esbuild-preprocessor": "^2.2.1", "cypress": "^13.12.0", "multiple-cucumber-html-reporter": "^3.6.2", "ts-loader": "^9.5.1" }, "cypress-cucumber-preprocessor": { "stepDefinitions": "cypress/support/step_definitions/*/.js", "html": { "enabled": true, "output": "cypress/reports/cucumber-html/cucumber-report.html" }, "json": { "enabled": true, "formatter": "cucumber-json-formatter", "output": "cypress/reports/cucumber-json/cucumber-report.json" } } }

CYPRESS.CONFIG.ts

import { defineConfig } from "cypress"; import createBundler from "@bahmutov/cypress-esbuild-preprocessor"; import { addCucumberPreprocessorPlugin } from "@badeball/cypress-cucumber-preprocessor"; import { createEsbuildPlugin } from "@badeball/cypress-cucumber-preprocessor/esbuild";

export default defineConfig({ e2e: { specPattern: "*/.feature", async setupNodeEvents( on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions ): Promise { // This is required for the preprocessor to be able to generate JSON reports after each run, and more, await addCucumberPreprocessorPlugin(on, config);

on( "file:preprocessor", createBundler({ plugins: [createEsbuildPlugin(config)], }) );

// Make sure to return the config object as it might have been modified by the plugin. return config; }, }, });

badeball commented 1 week ago

state.messages.current.findLastIndex is not a function

This is answered in the FAQ.

As for the following error:

Expected there to be a timestamp for current step (this might be a bug, please report at https://github.com/badeball/cypress-cucumber-preprocessor)

.. you need to provide a reproducible example and not just snippets of what information you think is relevant.

topesho commented 1 week ago

ok will provide the example project on Monday

badeball commented 1 week ago

I recommend that you just update your node version as per the FAQ, before trying anything else.

badeball commented 1 day ago

Closing due to lack of a reproducible example. Feel free to open up another issue if anything changes in this regard.