Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dont always display inline screenshots in system testing (#28133) #28185

Merged
merged 1 commit into from
Mar 13, 2017

Conversation

renchap
Copy link
Contributor

@renchap renchap commented Feb 26, 2017

Fixes #28133

3 output types are supported:

  • simple: only display the screenshot path
  • artifact: display the screenshot in the terminal, using the artifact protocol (supported by some CI)
  • inline (default): display the screenshot in the terminal, inline (supported by some terminals)

You can force the output type by setting the RAILS_SYSTEM_TESTING_SCREENSHOTS_OUTPUT environment variable

I am not sure if the documentation should be updated.

Also inline screenshot (http://iterm2.com/documentation-images.html) is only supported by a few terminals. On a mac, Terminal.app displays an empty line and iTerm displays the inline image. Some terminals might display the Base64-encoded screenshot instead. I dont know if we want to add some kind of detection or this is even possible (without having a whitelist of TERM_PROGRAM values).

output_type ||= "simple" if ENV["CI"]

# Default
output_type ||= "inline"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move output type to a method? I also think RAILS_SYSTEM_TESTING_SCREENSHOTS_OUTPUT is a really long env var so maybe something like RAILS_SYSTEM_TESTING_SCREENSHOT

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in the last commit

end

message
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't test this locally right now so maybe I'm reading it wrong - but it seems like this no longer outputs the path to the image on failure? I use the tmp path a lot when developing locally to open and look at the screenshot.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does, I moved it to line 41. I needed to do this because I wanted to avoid puts display_message if display_message, so now display_message returns the whole message to be displayed.

For example:

[Screenshot]: tmp/screenshots/failure_test_home_page.png
<inline image if enabled>

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see now. 👍

@renchap
Copy link
Contributor Author

renchap commented Mar 9, 2017

@eileencodes I adressed your comments, could you please review?

@@ -38,14 +37,32 @@ def save_image
page.save_screenshot(Rails.root.join(image_path))
end

def output_type
# Environment variables have priority
output_type = ENV["RAILS_SYSTEM_TESTING_SCREENSHOT"] || ENV["CAPYBARA_INLINE_SCREENSHOT"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is looking good. I think however this does need to be documented in the take_screenshot method so folks know how to use these environment variables.

3 output types are supported:
- simple: only display the screenshot path
- artifact: display the screenshot in the terminal, using the artifact protocol (supported by some CI)
- inline (default): display the screenshot in the terminal, inline (supported by some terminals)

You can force the output type by setting the `RAILS_SYSTEM_TESTING_SCREENSHOT` environment variable
@renchap renchap force-pushed the system-testing-screenshot-output branch from 3ecc3d9 to 79435c0 Compare March 11, 2017 22:17
@renchap
Copy link
Contributor Author

renchap commented Mar 11, 2017

@eileencodes here you go, with documentation added to the take_screenshot method.

@eileencodes eileencodes merged commit 5a05305 into rails:master Mar 13, 2017
@eileencodes
Copy link
Member

Thanks for working on this @renchap!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants