The JQuery DataTables plugin isn't loading for my Capybara integration tests, using Poltergeist as my JS driver.
Initially my test was supposed to click the DataTables header to sort the table, but when that didn't work I changed my tests to see if DataTables isn't being loaded at all. It isn't.
There are no errors in the test logs, and it works fine with manual browser testing (no JS console errors, either). All gems are up to date.
The driver works fine with other areas of the app using JQuery/JS. It's just this specific plugin that won't load.
Integration test
class ClientFlowsTest < ActionDispatch::IntegrationTest
setup :use_js_driver
setup do
@user = User.create(email: "ben@lawtons.com", password: "isthisgood?", password_confirmation: "isthisgood?")
#create 10 clients for the user (pagination limit is 9)
for i in 1..10
@user.clients.create(name: "Happy client #{i}")
end
sign_in @user
end
test "sort list of clients" do
visit clients_path
click_link "sidebar-client-index"
# should be present even without DataTables
assert page.has_css? "#client-table"
# should only be present if DataTables has loaded
assert page.has_css? "#client-table_wrapper"
end
end
Console output
rake test test/integration/client_flows_test.rb
Run options: --seed 10558
# Running:
Fontconfig warning: ignoring C.UTF-8: not a valid language tag
F
Finished in 3.320688s, 0.3011 runs/s, 0.6023 assertions/s.
1) Failure:
ClientFlowsTest#test_sort_list_of_clients [/home/ubuntu/workspace/test/integration/client_flows_test.rb:23]:
Expected false to be truthy.
1 runs, 2 assertions, 1 failures, 0 errors, 0 skips