3

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 ?!

k4v3
  • 55
  • 7

1 Answers1

3

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.
Sebastiano Schwarz
  • 1,060
  • 2
  • 13
  • 32