Been googling for a couple days now with no luck about the following issue: I've got a system test using Minitest(5.11.3), capybara(2.13.0) and capybara-webkit(1.14.0), said tests fail on 2 specific views that are javascript dependant: View1 hides/displays fields according to a dropdown selection, View2 charges data on fields by AJAX request based on user's selection on another dropdown.
Current configuration:
require 'test_helper'
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
driven_by :webkit
Capybara.javascript_driver = :webkit
end
Overhead config (been paranoid, just in case)
setup do
Capybara.current_driver = Capybara.javascript_driver
end
Still, clicks and assertions fail because the Javascript is not being executed, so, expected changes on the views never happen. Needless to say, it works seamlessly in development :).
Most likely this is because you're using
capybara-webkitwhich is based on QtWebkit. If built with any of the release versions of QtWebkit it doesn't support JS > ES5.1. This means if you are using any modern JS features (let/const/ methods added to standard objects in ES6, etc) and aren't fully transpiling/polyfilling to be be ES5 compatible the JS will throw errors and therefore not run. You can confirm this by running with selenium (headless chrome if you need headless) and see whether your tests work there.Note: You shouldn't need to set
javascript_driverdirectly if usingdriven_bywith system tests, and you probably want to upgrade Capybara to at least the latest 2.x version.