allure-framework / allure-js

Allure integrations for JavaScript test frameworks
https://allurereport.org/
Apache License 2.0
224 stars 119 forks source link

[allure-cypress] cy.task('allureReportTest') causing some test flakiness #1064

Open RobertBattaglia opened 1 month ago

RobertBattaglia commented 1 month ago

Describe the bug

To Reproduce Tough to reproduce, seems a race condition. Stack trace:

From Node.js Internals:
  TypeError: Cannot read properties of undefined (reading 'stage')
      at allureReportTest (/builds/redadcted/npm/src/main/npm/node_modules/allure-cypress/dist/reporter.js:3358:38)
      at invoke (/builds/redadcted/cache/Cypress/13.5.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_plugins.js:248:16)
      at <unknown> (/builds/redadcted/cache/Cypress/13.5.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/util.js:59:14)
      at tryCatcher (/builds/redadcted/cache/Cypress/13.5.0/Cypress/resources/app/node_modules/bluebird/js/release/util.js:16:23)
      at Function.Promise.attempt.Promise.try (/builds/redadcted/cache/Cypress/13.5.0/Cypress/resources/app/node_modules/bluebird/js/release/method.js:39:29)
      at Object.wrapChildPromise (/builds/redadcted/cache/Cypress/13.5.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/util.js:58:23)
      at RunPlugins.taskExecute (/builds/redadcted/cache/Cypress/13.5.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_plugins.js:254:10)
      at RunPlugins.execute (/builds/redadcted/cache/Cypress/13.5.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_plugins.js:166:21)
      at EventEmitter.<anonymous> (/builds/redadcted/cache/Cypress/13.5.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_plugins.js:56:12)
      at EventEmitter.emit (node:events:517:28)
      at EventEmitter.emit (node:domain:489:12)
      at process.<anonymous> (/builds/redadcted/cache/Cypress/13.5.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/util.js:33:22)
      at process.emit (node:events:517:28)
      at process.emit (node:domain:489:12)
      at process.emit.sharedData.processEmitHook.installedValue [as emit] (/builds/redadcted/cache/Cypress/13.5.0/Cypress/resources/app/node_modules/@cspotcode/source-map-support/source-map-support.js:745:40)
      at emit (node:internal/child_process:944:14)
      at processTicksAndRejections (node:internal/process/task_queues:83:21)

Expected behavior No tests should fail BECAUSE of the plugin. I would rather lose data than cause flaky tests.

Additional context version 2.14

baev commented 1 month ago

the problem should be already fixed in allure-cypress@3.0.0-beta.6, could you please give it a try

RobertBattaglia commented 1 month ago

For context, with Cypress v 13.4.0 node version 20.9.0 Trying to use the 3.0.0-beta any version I get:

Oops...we found an error preparing this test file:

  > cypress/support/e2e.ts

The error was:

SyntaxError: Unexpected token (1:3594) while parsing /e2e/node_modules/allure-cypress/dist/cjs/index.js while parsing file: /e2e/node_modules/allure-cypress/dist/cjs/index.js
    at DestroyableTransform.end [as _flush] (/e2e/node_modules/insert-module-globals/index.js:114:21)
    at DestroyableTransform.prefinish (/e2e/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:138:10)
    at DestroyableTransform.emit (node:events:514:28)
    at DestroyableTransform.emit (node:domain:488:12)
    at prefinish (/e2e/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:619:14)
    at finishMaybe (/e2e/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:627:5)
    at endWritable (/e2e/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:638:3)
    at DestroyableTransform.Writable.end (/e2e/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:594:22)
    at DestroyableTransform.onend (/e2e/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:577:10)
    at Object.onceWrapper (node:events:628:28)
    at DestroyableTransform.emit (node:events:526:35)
    at DestroyableTransform.emit (node:domain:488:12)
    at endReadableNT (/e2e/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:1010:12)
at processTicksAndRejections (node:internal/process/task_queues:82:21