teampoltergeist / poltergeist

A PhantomJS driver for Capybara
MIT License
2.5k stars 415 forks source link

Extensions doesn't raise for invalid paths #867

Closed rhys-vdw closed 7 years ago

rhys-vdw commented 7 years ago
Capybara.register_driver :poltergeist do |app|
  options = {
    screen_size: [1920, 1080],
    window_size: [1920, 1080],
    extensions: [
      Rails.root.join("some-non-existent-file").to_s,
    ]
  }
  Capybara::Poltergeist::Driver.new(app, options)
end

Tests just run as per usual without any complaint about the dependency not existing. Is there any way to check if a file has been loaded?

twalpole commented 7 years ago

We don't currently check the result code of the phantomjs injectJs call - https://github.com/teampoltergeist/poltergeist/blob/master/lib/capybara/poltergeist/client/browser.coffee#L78 - we probably should be checking it and returning an error if false

rhys-vdw commented 7 years ago

Cool. Is there any way in the short term that I can check? I'm trying to load in babel-polyfill but I'm getting this error:

TypeError: undefined is not a constructor (evaluating 'document.querySelectorAll('[data-react-mount]').forEach(mountReact)')
    at http://localhost:3808/assets/application.js:79448
    at http://localhost:3808/assets/application.js:76961
    at :0 in forEach
    at http://localhost:3808/assets/application.js:76960
    test/integration/taking_third_party_ordered_tests_test.rb:75:in `block in <class:TakingThirdPartyOrderedTestsTest>'
rhys-vdw commented 7 years ago

Ah, all good, I got a solution for this particular case:

  if (includes(window.navigator.userAgent, 'PhantomJS') && !window._babelPolyfill) {
    throw new Error('Babel Polyfill has not been installed!')
  }

Would you like a PR for the above issue? I'm not at all familiar with the Poltergeist code base.

twalpole commented 7 years ago

@rhys-vdw it'll probably take me a week or two to get to it, if you are able to submit a PR before that it would be great.

twalpole commented 7 years ago

Got to it quicker than expected

twalpole commented 7 years ago

Released in 1.14.0

rhys-vdw commented 7 years ago

Thanks @twalpole! 👍