How to save artifacts (protractor screenshots) for failed builds?

jeroen.heijmans's Avatar

jeroen.heijmans

03 Jan, 2020 01:20 PM

In my Angular 8 repository I've got my end-to-end tests produce PNG screenshots from the (headless) browser whenever a spec fails. Let's say I save only the latest file with jasmine and protractor here:

./my-reports/last-failure-screenshot.png

After creating said screenshot, the test_script step in appveyor.yml will report a failure, and the build will break off.

How could I then expose said file to developers that look at the failed build in the AppVeyor UI? The less friction, the better: ideally they can look at the build output, see the failed spec that caused the build to break, and click a link to open the screenshot.

I thought about using artifacts for this, but I suppose that's meant for successful builds, right?

How can I do this in my yml file or otherwise?


To clarify:

I've got this yml for running the tests:

test_script:
  - npm run lint
  - npm test -- --progress=false
  - npm run e2e
  - npm run build -- --progress=false

I've forced it (for now) to always output said png file. Based on this other support thread I've appended this to my yml file:

on_failure:
  - appveyor PushArtifact './jasmine-reports/last-failed-spec.png'

...but it does not have the desired effect. I presume this is because the npm run e2e call exits pretty harshly, the log says:

[14:07:18] E/launcher - Process exited with error code 1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-project@0.0.0 e2e: `node prebuild.js && ng e2e`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the my-project@0.0.0 e2e script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\appveyor\AppData\Roaming\npm-cache\_logs\2020-01-03T14_07_18_921Z-debug.log
Command exited with code 1

I've also tried putting a -artifacts section as a child (indedted) of the - npm run e2e line, but it didn't work either.

  1. 1 Posted by jeroen.heijmans on 03 Jan, 2020 03:16 PM

    jeroen.heijmans's Avatar

    Turned out the on_failure variant errored with:

    File not found: C:\projects\my-project\'\jasmine-reports\last-failed-spec.png'
    Command exited with code 2
    

    so the ./ part of the yml instruction was causing issues. After removing that, there were more errors, because the quotes also got included verbatim, causing a similar error. After removing that as well, it started working.

  2. jeroen.heijmans closed this discussion on 03 Jan, 2020 03:16 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac