teampoltergeist / poltergeist

A PhantomJS driver for Capybara

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Extensions doesn't raise for invalid paths

rhys-vdw opened this issue · comments

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?

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

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>'

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.

@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.

Got to it quicker than expected

Released in 1.14.0