percy / percy-capybara

Visual testing for Capybara with Percy.
https://docs.percy.io/docs/capybara
MIT License
45 stars 23 forks source link

disable javascript for a snapshot #52

Closed joscha closed 3 years ago

joscha commented 6 years ago

Hi,

I am trying to take a percy snapshot of a page and want to load it w/o Javascript.

I tried:

describe 'w/o JS', :editor => true, type: :feature, js: false do
// ...
end

without success.

I also tried:

Percy::Capybara.snapshot(page, name: 'w/o JS', enable_javascript: false)

which didn't work either. Then I had a look at https://github.com/percy/percy-capybara/blob/e1c80b350530f591324541646a0650adbc3c6653/spec/spec_helper.rb#L36 which led me to https://github.com/teampoltergeist/poltergeist/issues/489

I am running out of ideas on how to make this work - any hints?

djones commented 6 years ago

Hi @joscha,

There's a few subtle differences in your examples:

Disabling JavaScript for a test in your test suite

describe 'w/o JS', js: false do
  # ...
end

^ this will disable JavaScript when running a test in your test suite.

Disabling JavaScript when Percy renders your snapshot

Percy::Capybara.snapshot(page, name: 'w/o JS', enable_javascript: false)

^ this simple tells Percy to disable JavaScript when Percy loads up your page in Percy's rendering infrastructure. This is where we take the snapshot.

Important clarification

https://github.com/percy/percy-capybara/blob/e1c80b350530f591324541646a0650adbc3c6653/spec/spec_helper.rb#L36

^ this is simply percy-capybara's built-in test suite setting (sorry that's kinda meta!) but it has no impact on your tests and codebase.


If you are running Percy::Capybara.snapshot(page, name: 'w/o JS', enable_javascript: false) and JavaScript still appears to be running in the snapshot you see in Percy, let's chat more on customer support because that should indeed disable JavaScript.

Cheers, David.

joscha commented 6 years ago

Hi David,

Thanks for the clarification, that makes sense! Sorry for the confusion about the spec helper, I thought it was the base class for the capybara run - it seems like option 2 is what I wanted, however

If you are running Percy::Capybara.snapshot(page, name: 'w/o JS', enable_javascript: false) and JavaScript still appears to be running in the snapshot you see in Percy, let's chat more on customer support because that should indeed disable JavaScript.

I sent you a message there because this seems as if indeed the page is snapshot with JS. Maybe the fallback to JS on for omission of enable_javascript isn't trumped by the explicit false?