badeball / cypress-cucumber-preprocessor

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

Hook failures can't be represented in any reports (messages / json / html), thus none is created #1149

Closed akshaygupta5233 closed 5 months ago

akshaygupta5233 commented 6 months ago

Current behavior Since there are so many running tests for me it's overloading the browser and eventually crashing it. I came up with 'NO_COMMAND_LOG: 1', which I have kept under env in config file, so that there are no logs created and keeping browser light. But I am observing this error whenever I run the 'npx cypress open'. Error: "before all" hook for "Test case name" Hook failures can't be represented in any reports (messages / json / html), thus none is created for 'my feature file name'

Desired behavior The execution should happen without error and no logs should be shown in UI

Test code to reproduce This is my cypress.config.ts mentioned below -`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: { baseUrl: " a working test url", hideXhr: true, NO_COMMAND_LOG: 1, testIsolation: true }, viewportWidth: 1600, viewportHeight: 900, numTestsKeptInMemory: 0, e2e: { defaultCommandTimeout: 40000, experimentalMemoryManagement: 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; }, }, });`

I dont have 'before all' hook in my code, still the error

COmmand to execute : npx cypress open

**Cypress Version 13.6.2

Node version 18+

Operating System macOS 14**

Debug Logs }, cypress:util:crash_handling hooks: [ cypress:util:crash_handling { cypress:util:crash_handling hookId: 'h1', cypress:util:crash_handling hookName: 'before all', cypress:util:crash_handling title: [Array], cypress:util:crash_handling body: 'function() {\n addStyles();\n }' cypress:util:crash_handling } cypress:util:crash_handling ], cypress:util:crash_handling tests: [ cypress:util:crash_handling { cypress:util:crash_handling testId: 'r3', cypress:util:crash_handling title: [Array], cypress:util:crash_handling state: 'skipped', cypress:util:crash_handling body: 'function() {\n' + cypress:util:crash_handling ' var _a2, _b, _c, _d, _e;\n' + cypress:util:crash_handling ' const { remainingSteps, testCaseStartedId } = retrieveInternalSpecProperties();\n' + cypress:util:crash_handling ' taskTestCaseStarted(context, {\n' + cypress:util:crash_handling ' id: testCaseStartedId,\n' + cypress:util:crash_handling ' testCaseId,\n' + cypress:util:crash_handling ' attempt: attempt++,\n' + cypress:util:crash_handling ' timestamp: (0, messages_1.createTimestamp)()\n' + cypress:util:crash_handling ' });\n' + cypress:util:crash_handling ' window.testState = {\n' + cypress:util:crash_handling ' gherkinDocument,\n' + cypress:util:crash_handling ' pickles,\n' + cypress:util:crash_handling ' pickle\n' + cypress:util:crash_handling ' };\n' + cypress:util:crash_handling ' for (const step of steps) {\n' + cypress:util:crash_handling ' if (step.hook) {\n' + cypress:util:crash_handling ' const hook = step.hook;\n' + cypress:util:crash_handling ' const testStepId = getTestStepId({\n' + cypress:util:crash_handling ' context,\n' + cypress:util:crash_handling ' pickleId: pickle.id,\n' + cypress:util:crash_handling ' hookIdOrPickleStepId: hook.id\n' + cypress:util:crash_handling ' });\n' + cypress:util:crash_handling ' cy.then(() => {\n' + cypress:util:crash_handling ' delete window.testState.pickleStep;\n' + cypress:util:crash_handling ' const start = (0, messages_1.createTimestamp)();\n' + cypress:util:crash_handling ' internalProperties.currentStepStartedAt = start;\n' + cypress:util:crash_handling ' taskTestStepStarted(context, {\n' + cypress:util:crash_handling ' testStepId,\n' + cypress:util:crash_handling ' testCaseStartedId,\n' + cypress:util:crash_handling ' timestamp: start\n' + cypress:util:crash_handling ' });\n' + cypress:util:crash_handling ' return cy.wrap(start, { log: false });\n' + cypress:util:crash_handling ' }).then((start) => {\n' + cypress:util:crash_handling ' (0, cypress_1.runStepWithLogGroup)({\n' + cypress:util:crash_handling ' fn: () => registry2.runHook(this, hook),\n' + cypress:util:crash_handling ' keyword: hook.keyword,\n' + cypress:util:crash_handling ' text: hook.tags\n' + cypress:util:crash_handling ' });\n' + cypress:util:crash_handling ' return cy.wrap(start, { log: false });\n' + cypress:util:crash_handling ' }).then((start) => {\n' + cypress:util:crash_handling ' const end = (0, messages_1.createTimestamp)();\n' + cypress:util:crash_handling ' taskTestStepFinished(context, {\n' + cypress:util:crash_handling ' testStepId,\n' + cypress:util:crash_handling ' testCaseStartedId,\n' + cypress:util:crash_handling ' testStepResult: {\n' + cypress:util:crash_handling ' status: messages.TestStepResultStatus.PASSED,\n' + cypress:util:crash_handling ' duration: (0, messages_1.duration)(start, end)\n' + cypress:util:crash_handling ' },\n' + cypress:util:crash_handling ' timestamp: end\n' + cypress:util:crash_handling ' });\n' + cypress:util:crash_handling ' remainingSteps.shift();\n' + cypress:util:crash_handling ' });\n' + cypress:util:crash_handling ' } else if (step.pickleStep) {\n' + cypress:util:crash_handling ' const pickleStep = step.pickleStep;\n' + cypress:util:crash_handling ' const testStepId = getTestStepId({\n' + cypress:util:crash_handling ' context,\n' + cypress:util:crash_handling ' pickleId: pickle.id,\n' + cypress:util:crash_handling ' hookIdOrPickleStepId: pickleStep.id\n' + cypress:util:crash_handling ' });\n' + cypress:util:crash_handling ' const text = (0, assertions_1.assertAndReturn)(pickleStep.text, "Expected pickle step to have a text");\n' + cypress:util:crash_handling ' const scenarioStep = (0, assertions_1.assertAndReturn)(context.astIdsMap.get((0, assertions_1.assertAndReturn)((_a2 = pickleStep.astNodeIds) === null || _a2 === void 0 ? void 0 : _a2[0], "Expected to find at least one astNodeId")), Expected to find scenario step associated with id = ${(_b = pickleStep.astNodeIds) === null || _b === void 0 ? void 0 : _b[0]});\n' + cypress:util:crash_handling ' const argument = ((_c = pickleStep.argument) === null || _c === void 0 ? void 0 : _c.dataTable) ? new data_table_1.default(pickleStep.argument.dataTable) : ((_e = (_d = pickleStep.argument) === null || _d === void 0 ? void 0 : _d.docString) === null || _e === void 0 ? void 0 : _e.content) ? pickleStep.argument.docString.content : void 0;\n' + cypress:util:crash_handling ' cy.then(() => {\n' + cypress:util:crash_handling ' window.testState.pickleStep = step.pickleStep;\n' + cypress:util:crash_handling ' const start = (0, messages_1.createTimestamp)();\n

badeball commented 6 months ago

https://github.com/badeball/cypress-cucumber-preprocessor/issues/1147#issuecomment-1887054697

badeball commented 5 months ago

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