Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Publish Cypress screenshots in Azure DevOps (or externally)

I'm relatively new with Azure DevOps and I was wondering what will be the most practical way to publish Cypress test screenshots in Azure pipelines (or maybe even somewhere external)?

The only way I found online is this: http://codestyle.dk/2020/05/19/cypress-screenshots-are-missing-in-azure-pipelines/

But maybe there is some more "practical" solution ?!

like image 565
k4v3 Avatar asked Jan 19 '26 17:01

k4v3


1 Answers

To publish the screenshots of your failed Cypress tests, you can add the following task to your pipeline definition .yaml file after running your tests. This will publish all created screenshots in the pipeline artifacts of the current pipeline run.

- task: PublishBuildArtifacts@1
  displayName: 'Publish Cypress Screenshot Files'
  condition: failed()
  inputs:
    PathtoPublish: 'cypress/screenshots/'
    ArtifactName: 'screenshots'

Two notes about this:

  1. If you want to publish screenshots not only when the tests fail, then you have to remove the line condition: failed()
  2. The cypress/screenshots folder is only automatically created by Cypress if the test execution also creates screenshots. If no screenshot was created, then the folder does not exist and the above pipeline task would fail. Therefore I would also persist the empty screenshots folder in the repo by using a .gitkeep file.
like image 196
Sebastiano Schwarz Avatar answered Jan 22 '26 11:01

Sebastiano Schwarz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!