Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Screenshot is not saved when test case throws an Error #2690

Closed
badiale opened this issue Nov 9, 2015 · 2 comments
Closed

Screenshot is not saved when test case throws an Error #2690

badiale opened this issue Nov 9, 2015 · 2 comments

Comments

@badiale
Copy link

badiale commented Nov 9, 2015

Following this FAQ, we took screenshots of our test cases on version 1.8.0.
But on upgrading to the lastest version, the screenshot stopped to work on test cases which throw erros.
We used this to abort the test when one expectation can invalidate the complete test case, evicting a cascading failure.

To illustrate this scenario, I made a simple git project, with three test cases:

  1. one wich fails a expectation and a screenshot is successfully taken;
  2. one wich fails with an error, but no screenshot is taken, or an empty image is generated;
  3. one wich is ignored, but if you enable it, the second case will have a correct screenshot taken.

The problem seems to be that the protractor process is closed before the file is completely saved, but I'm not sure.

@juliemr
Copy link
Member

juliemr commented Nov 10, 2015

Yes, this is because the runner process has finished, so Protractor is cleaning up without knowing to wait. (See https://github.com/angular/protractor/blob/master/lib/launcher.js#L257). I'm not sure if this counts as a bug, or just an annoying side effect - usually, we do want to make sure that the process quits and doesn't hang unexpectedly. Additionally, when running in one process (which we do if there's no sharding requested, and which is desirable for debugging), we actually can't wait on the process to exit because we've got other waits and things we need to do.

The easy way around this is to have a onCleanUp or afterLaunch task which flushes all of your outputs and returns a promise when that's all done.

We should mention this in the FAQ example. Changing the type of this issue to 'docs'.

@juliemr
Copy link
Member

juliemr commented Jul 14, 2016

Closing as dupe of #1938

@juliemr juliemr closed this as completed Jul 14, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants