Closed akshaygupta5233 closed 3 months ago
@badeball Kindly help me on this
As I've already explained in other issues of yours - I can't help you unless you provide me with reproducible examples. A configuration file simply doesn't tell the whole story here.
This error is originated from @cucumber/cucumber
https://github.com/cucumber/cucumber-js/blob/9e4d7bd2e85a4342837956308c874b3f67bec14e/src/formatter/json_formatter.ts#L281C5-L281C47.
There testStepResult
is handling. If we have testStepResult then proceed with the logic else not. Just one if condition can fix this issue I believe. This issue should be fixed by @cucumber/cucumber
side it seems.
Even I am also getting this issue, but it's very difficult to understand that which scenario it's coming on? as it is not consistent. But this issue was not there for lower versions like 15.0.0
I hope this comment will help to fix this issue.
If we have testStepResult then proceed with the logic else not. Just one if condition can fix this issue I believe. This issue should be fixed by
@cucumber/cucumber
side it seems.
No. The JsonFormatter is a stateful component and it expects there to be a testStepResult
at that point. Anything else means that the envelopes sent by this library are wrong. Maintaining envelope state is where all edge cases are taken into account.
This is why you both need to provide reproducible examples, as I can't determine your edge case otherwise.
Same problem, I could not change anything but I saw same fail last time
We have the same issue. This occurs for us when chrome crashes during test execution. It's particularly a problem because for us it leads to a false positive even though the test did not run and pass.
@badeball To reproduce this do the following:
cypress run --env TAGS="@focus" --browser chrome --headed
chrome://inducebrowsercrashforrealz
You will then see this error.
This is a very real scenario as cypress has issues with memory crashes lately. I appreciate the plugin may not be able to handle full reporting in this instance, but not erroring out like this is very important since it breaks our other plugin that also uses the after:run event.
@AMEntwistle, are you seeing the same error as depicted in OP's screenshot?
@badeball Yes same error:
TypeError: Cannot destructure property 'message' of 'testStepResult'
Given the this example, if I navigate to chrome://inducebrowsercrashforrealz
during the pause, I get the following error.
An error was thrown in your plugins file while executing the handler for the after:spec event.
The error we received was:
Error: Unexpected state in afterSpecHandler: step-started (this might be a bug, please report at https://github.com/badeball/cypress-cucumber-preprocessor)
at createError (/home/jonas/projects/reproducible-issues/cypress-cucumber-preprocessor/crash-during-step/node_modules/@badeball/cypress-cucumber-preprocessor/dist/helpers/error.js:9:12)
at afterSpecHandler (/home/jonas/projects/reproducible-issues/cypress-cucumber-preprocessor/crash-during-step/node_modules/@badeball/cypress-cucumber-preprocessor/dist/plugin-event-handlers.js:276:43)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
Are you doing something different?
My bad, looks like I was on an older plugin version. I see what you do on the latest. I suppose this is a separate issue to what's mentioned here.
Given the this example, if I navigate to
chrome://inducebrowsercrashforrealz
during the pause, I get the following error.An error was thrown in your plugins file while executing the handler for the after:spec event. The error we received was: Error: Unexpected state in afterSpecHandler: step-started (this might be a bug, please report at https://github.com/badeball/cypress-cucumber-preprocessor) at createError (/home/jonas/projects/reproducible-issues/cypress-cucumber-preprocessor/crash-during-step/node_modules/@badeball/cypress-cucumber-preprocessor/dist/helpers/error.js:9:12) at afterSpecHandler (/home/jonas/projects/reproducible-issues/cypress-cucumber-preprocessor/crash-during-step/node_modules/@badeball/cypress-cucumber-preprocessor/dist/plugin-event-handlers.js:276:43) at processTicksAndRejections (node:internal/process/task_queues:95:5)
Are you doing something different?
I have a issue https://github.com/badeball/cypress-cucumber-preprocessor/issues/1166 for this error. This may help to fix that issue.
I have a issue https://github.com/badeball/cypress-cucumber-preprocessor/issues/1166 for this error. This may help to fix that issue.
It won't. You need to provide reproducible examples to your issues.
Closing due to lack of a reproducible example. Feel free to open up another issue if anything changes in this regard.
Hi @akshaygupta5233, I was having the same issue
The problem was baseUrl
!= url actually visited (cy.visit('other_url_than_the_one_defined_for_baseUrl)
)
Visit the same url you defined in baseUrl
and it should be fine
It worked for me, hope it helps
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 ()
at /app/node_modules/@cucumber/cucumber/src/formatter/json_formatter.ts:159:58
at Array.map ()
at /app/node_modules/@cucumber/cucumber/src/formatter/json_formatter.ts:155:30
at Array.map ()
at JsonFormatter.onTestRunFinished (/app/node_modules/@cucumber/cucumber/src/formatter/json_formatter.ts:147:59)
at EventEmitter. (/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 {
await addCucumberPreprocessorPlugin(on, config);
on(
"file:preprocessor",
createBundler({
plugins: [createEsbuildPlugin(config)],
})
);
return config;
},
},
});
Versions
Checklist
cypress-cucumber-preprocessor@4.3.1
(package name has changed and it is no longer the most recent version, see #689).