allure-framework / allure-js

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

[Cypress] Tests fail on `reportAllureCypressSpecMessages` task during screenshots copying #1133

Open M-Burzynski opened 2 months ago

M-Burzynski commented 2 months ago

Describe the bug When using the allure-cypress with the cypress-plugin-snapshots for visual regression tests, when a test fails on a screenshot comparison, then the after hook fails with an error:

CypressError: cy.task('reportAllureCypressSpecMessages') fails with the following error:
> ENOENT: no such file or directory, copyfile '/var/lib/jenkins/workspace/project-name/cypress/screenshots/spec_name.cy.js/screenshot_name #0.png' -> 'cypress/reports/allure-results/81429aaa-74cf-49ff-8c2c-447d718fa405-attachment.png'
https://on.cypress.io/api/task
Because this error occurred during a `after each` hook we are skipping all of the remaining tests.
      at <unknown> (http://localhost:4173/__cypress/runner/cypress_runner.js:135481:70)
      at tryCatcher (http://localhost:4173/__cypress/runner/cypress_runner.js:1807:23)
      at Promise._settlePromiseFromHandler (http://localhost:4173/__cypress/runner/cypress_runner.js:1519:31)
      at Promise._settlePromise (http://localhost:4173/__cypress/runner/cypress_runner.js:1576:18)
      at Promise._settlePromise0 (http://localhost:4173/__cypress/runner/cypress_runner.js:1621:10)
      at Promise._settlePromises (http://localhost:4173/__cypress/runner/cypress_runner.js:1697:18)
      at _drainQueueStep (http://localhost:4173/__cypress/runner/cypress_runner.js:2407:12)
      at _drainQueue (http://localhost:4173/__cypress/runner/cypress_runner.js:2400:9)
      at Async._drainQueues (http://localhost:4173/__cypress/runner/cypress_runner.js:2416:5)
      at Async.drainQueues (http://localhost:4173/__cypress/runner/cypress_runner.js:2286:14)
  From Your Spec Code:
      at $.flushAllureMessagesToTask (webpack:///../../node_modules/allure-cypress/dist/cjs/index.js:1:12072)
      at [Context.ee](http://context.ee/) (webpack:///../../node_modules/allure-cypress/dist/cjs/index.js:1:14228)

As cypress-plugin-snapshots stores visual regresion screenshots inside a folder e2e/spec_name but the allure-cypress plugin tries to copy all the screenshots taken during test run and assumes they all are saved inside screenshots folder, so it tries to copy screenshots from the path which is not correct. Is there any way to configure which screenshots should be copied and which not? Or any other way to avoid this problem and ignore the fail in after hook? Currently the whole tests suite stops when this error occurs.

To Reproduce Steps to reproduce the behavior:

  1. Set up the cypress-plugin-snapshots and allure-cypress plugin in the repository
  2. Run the test script in which a screenshot comparison would fail
  3. See error described at the beginning

Expected behavior allure-cypress plugin shouldn't try to copy attatchments from non existing paths or it should be possible to configure which attatchments should be copied to the report. Screenshots

image

Desktop (please complete the following information):

nayanakb9 commented 1 month ago

Facing the same error. Please let know how to resolve

kwangecs commented 3 weeks ago

When using the allure-cypress integrating with the other plugins, the tests doesn't execute at all. Did try to install cypress-on-fix

Facing similar issue with version
allure-cypress Version ,"^3.0.5" and "^3.0.6" Cypress version [13.13] Browser [chrome] OS: [Mac]

Screenshot 2024-11-01 at 2 24 58 PM

1730489053613.log