Things get upvoted for a lot of reasons, chief of which is getting tips from people who use the same tool, like the comment that tops the list right now.
Capybara's a great too that we use heavily at https://www.incoin.io. One of the hangups we had is with multiple API endpoints being hit for a particular page. In some instances the first API request would finish and Capybara would assume that loading is done, when really there's another API request pending meaning our promises haven't yet finished and tests would fail randomly.
Other than that, Capybara is absolutely amazing. It doesn't replace manual UI testing by any means, though it provides a lot of confidence knowing we haven't broken critical components of our app.
If you use Capybara, a couple of useful notes, based on what I learned implementing js-enabled &headless specs for my SaaS [3]:
First, using the poltergeist driver [1] which is PhantomJS based will tend to be faster AND raise errors when a javascript error occurs (unlike capybara-webkit), which is really handy if your app has a bit of javascript.
Also, you can inject puffing-billy [2] into the mix: this is a proxy that will allow you to mock XHR queries without touching the javascript libraries. This allows to write full integration specs for scenarios involving libraries like Stripe/Recurly.js etc, but using mocked calls.
I recommend using the built-in Rack Test for tests that don't require Javascript, and Poltergeist for tests that do. That is the fastest configuration.
I think that your ultimate goal is to rely on Capybara for your testing as little as cleverly possible. Push all your logic into separately-unit-testable JS, perhaps use a DOM emulator, anything to get away from slow, barely-deterministic full browser Capybara testing.
19 comments
[ 3.0 ms ] story [ 49.0 ms ] threadEither way, I really enjoy Capybara -- especially being able to jump between different drivers for various reasons.
In order to prevent this you need to delay Capybara's processing so that all requests have finished using a request counter. Information is here: http://tonyhb.com/stop-treading-water-with-marionette-and-ca...
Other than that, Capybara is absolutely amazing. It doesn't replace manual UI testing by any means, though it provides a lot of confidence knowing we haven't broken critical components of our app.
First, using the poltergeist driver [1] which is PhantomJS based will tend to be faster AND raise errors when a javascript error occurs (unlike capybara-webkit), which is really handy if your app has a bit of javascript.
Also, you can inject puffing-billy [2] into the mix: this is a proxy that will allow you to mock XHR queries without touching the javascript libraries. This allows to write full integration specs for scenarios involving libraries like Stripe/Recurly.js etc, but using mocked calls.
[1] https://github.com/teampoltergeist/poltergeist
[2] https://github.com/oesmith/puffing-billy
[3] https://www.wisecashhq.com