Polyfills being loaded differently depending on host
kernow opened this issue · comments
Hi,
I'm trying to work out why our tests are failing with the message "Can't find variable: WeakMap" on our CI server running debian but passing locally on OSX.
Both machines are running poltergeist (1.14.0) and phantomjs (2.1.1) and run the same codebase. PhantomJS is installed via homebrew on OSX and via the file download on debian.
When running on OSX I have tried adding the polyfill for WeakMap as follows:
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(
app,
extensions: [File.expand_path("node_modules/babel-polyfill/dist/polyfill.js", Rails.root)],
phantomjs_options: [
"--load-images=no",
"--ignore-ssl-errors=yes",
"--ssl-protocol=TLSv1"
]
)
end
When running the tests with the above I get the following error:
Capybara::Poltergeist::JavascriptError:
One or more errors were raised in the Javascript code on the page. If you don't care about these errors, you can ignore them by setting js_errors: false in your Poltergeist configuration (see documentation for details).
Error: only one instance of babel-polyfill is allowed
Error: only one instance of babel-polyfill is allowed
at phantomjs://code/polyfill.js:12
at phantomjs://code/polyfill.js:31
at phantomjs://code/polyfill.js:1 in s
at phantomjs://code/polyfill.js:1 in e
It would appear that the polyfill is already loaded on OSX from somewhere but this is not happening on our debian CI server. Where is the polyfill coming from on OSX and how is it being configured? Can I either disable this on OSX and manually load the polyfills or get the same one loaded on debian?
Thanks
I'm sorry, there's no way for us to know where or why your system is loading a file twice. It sounds like probably an issue with your asset management (whatever you're using for that) setup, where the polyfill is already being included by the asset compilation. However, Poltergeist isn't including anything unless you tell it to.