-
Notifications
You must be signed in to change notification settings - Fork 227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should add gotchas to testing with Capybara in README #308
Comments
Hi there! Thanks for your feedback! To answer you briefly :
I have integration tests with Capybara and I've never had to implement this kind of trick. Everything worked out of the box. I suspect you might need this kind of trick when you want to test a Datatable with a lot of data, which can slow datatable rendering, due to long queries executions, and thus create errors during your tests. (cannot find tr with id 'foo' for example) I usually have 3 or 4 entries in my datatables during integration tests, where I click on 'actions links' :
and the datatables are always loaded in time. But thanks for the hint since everyone might not be as lucky as I am 👍
I admit it was one of the first thing I configured in Capybara. Since Puma is the default web server in Rails since Rails 5 (or so, can't remember) it was a non sense to me to not use it in tests ^^ (to avoid the usual story : it works in dev and not in test... yeah... dev uses Puma and test uses Webrick... ok) About this specific point : https://stackoverflow.com/a/38705340 Use Puma and The 414 (Request-URI Too Large) errors are due to the using of the With the default configuration, jQuery Datatables send requests with the The more columns you add in your datatable, the bigger the To avoid that, and by the way to not pollute your Nginx logs with big HTTP requests, use Use a dedicated route to do so. IMHO the With this and some little bits of metaprogrammig you can easily maintain tens of datatables. |
Regarding point 1. I agree this might be too much of an edge case. Regarding point 2. I totally missed this part https://github.com/jbox-web/ajax-datatables-rails#use-http-post-method-medium, and you're right. However I think it might be best to advise to configure Capybara to use Puma from the start. Closing this anyway, thanks @n-rodriguez |
I'm adding both to the README ;) Thank you! |
I've been struggling for a while trying to create integration tests that dealt with this library.
There are two things that would've saved me (and hopefully would save other devs) a lot of time had they been documented here:
Waiting for Ajax requests. Although not specific to this library, there's no way to test without knowing how to do this, and it's not the most thoroughly or widely documented trick. This guide worked well for me: https://robots.thoughtbot.com/automatically-wait-for-ajax-with-capybara
Configuring the test server used by Capybara to prevent this from breaking: https://stackoverflow.com/questions/27992619/capybara-selenium-webdriver-datatables-not-playing-nicely is a good reference.
The text was updated successfully, but these errors were encountered: