0

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
Ben Lawton
  • 29
  • 3
  • Maybe this [question](https://stackoverflow.com/questions/29809462/uncss-error-c-utf-8-not-a-valid-language-tag) can help you to answer yours. – Roshan Aug 23 '17 at 15:32

1 Answers1

0

Poltergeist depends on PhantomJS, the latest version (development has stopped on it, so probably last version) of which only supports up to ES5. If your code is using any ES5.1+ features it won't work, and can silently fail if you use things like let, const, etc. For the moment you're going to be much better off just swapping to testing with headless chrome via selenium.

Poltergeist is currently being rewritten to use Puppeteer rather than PhantomJS, so hopefully these limitations will go away soon.

Thomas Walpole
  • 48,548
  • 5
  • 64
  • 78