Page MenuHomePhabricator

Cypress: add folders to jenkins artifacts
Closed, ResolvedPublic

Description

when cypress tests fail, it creates screenshots and videos that can be useful to pinpoint the reason of the test fail.
right now we don't have access to those folders once the build finishes.
would be nice to have these folders added to the artefacts:

/workspace/src/cypress/screenshots/
/workspace/src/cypress/videos/

Event Timeline

The convention is to have the testsuite to write to a path given by the LOG_DIR environment variable (CI / Quibble set it). CI then just capture whatever is in that path and publish it as a build artifact.

An example from the webdriver.io configuration file:

tests/selenium/wdio.conf.js
const logPath = process.env.LOG_DIR || path.join( __dirname, '/log' );
...
reporters: [
  [
    'junit': { outputDir: logpath }
  ]
]
zeljkofilipin moved this task from Backlog 🪒 to Deep work 🌊 on the User-zeljkofilipin board.

@Jpita the easiest way to save cypress screenshots and videos is to save them to a location that Jenkins already archives. I'll take a look.

hashar removed hashar as the assignee of this task.Apr 1 2020, 5:47 PM
hashar subscribed.

I am not working on this, but you can follow my guidance from above :] Namely have Cypress to write the artifacts to the path pointed by LOG_DIR environment variable when it is available, else fall back to a log directory.

zeljkofilipin renamed this task from add folders to jenkins artifacts to Cypress: add folders to jenkins artifacts.Apr 8 2020, 5:57 PM

this is easily done by adding:
config.screenshotsFolder = process.env.LOG_DIR || path.join( __dirname, '../log' );
and
config.videosFolder = process.env.LOG_DIR || path.join( __dirname, '../log' );

to the cypress/plugins/index.js file.
Example here and here.

@Jpita sorry, it's been a while since you've reported this. I think this could be resolved like this:

tests/cypress/plugins/index.js

//...
config.screenshotsFolder = path.join( logPath, 'screenshots' );
//...

See 601343 and sample.spec.js.mp4.

zeljkofilipin claimed this task.