cypress-cucumber-preprocessor: TypeError: Cannot destructure property 'message' of 'testStepResult' as it is undefined.
Current behavior
When I run my tests in local or jenkins, I do see this error mentioned below- The error is way random and I am not able to understand at what point this error is coming. Because of this, my reports are not being generated.
An error was thrown in your plugins file while executing the handler for the after:run event. The error we received was: TypeError: Cannot destructure property ‘message’ of ‘testStepResult’ as it is undefined. at JsonFormatter.getStepData (/app/node_modules/@cucumber/cucumber/src/formatter/json_formatter.ts:281:13) at /app/node_modules/@cucumber/cucumber/src/formatter/json_formatter.ts:161:23 at Array.map (<anonymous>) at /app/node_modules/@cucumber/cucumber/src/formatter/json_formatter.ts:159:58 at Array.map (<anonymous>) at /app/node_modules/@cucumber/cucumber/src/formatter/json_formatter.ts:155:30 at Array.map (<anonymous>) at JsonFormatter.onTestRunFinished (/app/node_modules/@cucumber/cucumber/src/formatter/json_formatter.ts:147:59) at EventEmitter.<anonymous> (/app/node_modules/@cucumber/cucumber/src/formatter/json_formatter.ts:92:14) at EventEmitter.emit (node:events:526:35) at EventEmitter.emit (node:domain:488:12) at afterRunHandler (/app/node_modules/@badeball/cypress-cucumber-preprocessor/dist/plugin-event-handlers.js:134:30)
Desired behavior
The error should not appear and let the reports be generated.
Test code to reproduce
My cypress.config.ts file-
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”;
export default defineConfig({ env: { CYPRESS_PROCESS_PROFILER_INTERVAL: 60000, baseUrl: “A url”, }, viewportWidth: 1600, viewportHeight: 900, numTestsKeptInMemory: 0, scrollBehavior: “top”, screenshotOnRunFailure: true, e2e: { defaultCommandTimeout: 50000, testIsolation: true, experimentalMemoryManagement: true, experimentalInteractiveRunEvents: true, specPattern: “**/*.feature”, async setupNodeEvents( on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions ): Promise<Cypress.PluginConfigOptions> { await addCucumberPreprocessorPlugin(on, config); on( “file:preprocessor”, createBundler({ plugins: [createEsbuildPlugin(config)], }) ); return config; }, }, });
Versions
- Cypress version: 13.6.4
- Preprocessor version:18.0.4
- Node version:20+
Checklist
- I’ve read the FAQ.
- I’ve read instructions for logging issues.
- I’m not using
cypress-cucumber-preprocessor@4.3.1(package name has changed and it is no longer the most recent version, see #689).
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 21 (8 by maintainers)
Commits related to this issue
- Handle browser / page crash gracefully Related to #1161 [1], possible fixes it. [1] https://github.com/badeball/cypress-cucumber-preprocessor/issues/1161 — committed to badeball/cypress-cucumber-preprocessor by badeball 3 years ago
- Instruct users with JsonFormatter errors to attach messages Additionally, for users that haven't enabled messages, one is generated anyway in the users temporary location. This will hopefully shed so... — committed to badeball/cypress-cucumber-preprocessor by badeball 2 years ago
- Instruct users with JsonFormatter errors to attach messages Additionally, for users that haven't enabled messages, one is generated anyway in the users temporary location. This will hopefully shed so... — committed to badeball/cypress-cucumber-preprocessor by badeball 2 years ago
Also random for me on Cypress 14.4.1. It all worked well with Cypress 13 and lower.
Crash behavior in Cypress is a mess and always has been. It’s possible to simulate different types of crash in chromium, but this isn’t possible in firefox afaik. There was talk about supporting this. However, Cypress isn’t being developed in any meaningful way nowadays, so I wouldn’t count on ever seeing this improved.