allure-js icon indicating copy to clipboard operation
allure-js copied to clipboard

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

Open M-Burzynski opened this issue 1 year ago • 9 comments

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):

  • OS: [Ubuntu]
  • Browser [chrome]
  • allure-cypress Version [v3.0.0-beta.11]
  • Cypress version [13.14.1]

M-Burzynski avatar Sep 06 '24 14:09 M-Burzynski

Facing the same error. Please let know how to resolve

nayanakb9 avatar Oct 23 '24 12:10 nayanakb9

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

kwangecs avatar Nov 01 '24 19:11 kwangecs

Try with this config on your cypress.config.js

env: { preserveOriginalScreenshot: true, },

diefersoncruz avatar Dec 16 '24 19:12 diefersoncruz

@baev could you take a look at this issue and provide some feedback? Is it planned to fix this issue or is there any workaround? Currently this issue is a blocker for me in using allure-cypress in my project

M-Burzynski avatar Jan 22 '25 15:01 M-Burzynski

@M-Burzynski, could you please specify the versions of cypress, allure-cypress and cypress-plugin-snapshots?

baev avatar Jan 22 '25 15:01 baev

@M-Burzynski, could you please specify the versions of cypress, allure-cypress and cypress-plugin-snapshots?

@baev Today I checked it on the newest versions and issue still exists: cypress 14.0.0 allure-cypress 3.0.9 cypress-plugin-snapshots 1.4.4

M-Burzynski avatar Jan 22 '25 15:01 M-Burzynski

Thanks, we'll take a look shortly.

baev avatar Jan 22 '25 15:01 baev

Is there any updates on this issue? I have the same error. cypress 13.17.0 node 14.21.3 allure-cypress 3.0.6 If i will use the node 16 then the report will be generated successfully. @baev

nasvaytrip avatar Feb 25 '25 11:02 nasvaytrip

Support for Node versions < 18 has been dropped since release 3.0.0.

Allure Cypress is tested against Node.js 18 and higher. Older versions may work, but we can't guarantee that.

https://allurereport.org/docs/cypress/

There are no plans to support earlier versions. We usually follow the official Node release schedule, dropping support for unmaintained versions, see: https://nodejs.org/en/about/previous-releases

baev avatar Feb 25 '25 12:02 baev