3

I am using spinach, Capybara, and Poltergeist together to write automated UI tests. I have been trying to speed up running tests locally. I am using Spring which helps a little with the environment loading. However, the first request (visit) to the app server that Poltergeist starts is slow because Rails has to compile the assets the first time. I have tried starting a locally server in the test environment and then doing this in my spinach env.rb file:

::Capybara.run_server = false
::Capybara.app_host = "http://localhost:#{ENV['TEST_SERVER_PORT']}"

This makes debugging difficult because the web server is running in a different process than the spinach process. Also, precompiling assets is not a good solution because I don't want to have to run it every time I am tweaking things in a JS file and then running the tests to verify my changes.

Bottom line: has anyone figured out how to make the first test server request be faster?

gabe
  • 1,873
  • 2
  • 20
  • 36

2 Answers2

0

You could use parallel tests for Spinach

https://github.com/grosser/parallel_tests

It probably won't solve the issue with first request but it can speed up running all tests - which still might be beneficial for you

Piotr Brudny
  • 654
  • 4
  • 16
  • 1
    We already use `parallel_tests` for our CI pipeline, but this is more for our development workflow. I rerun the same test many times as I am developing a feature or fixing a feature. Waiting for the assets every time is a pain. Using unit tests instead would "solve" this but we are avoiding adding lots of unit tests if our UI tests already give the necessary coverage. – gabe Apr 07 '15 at 18:57
0

First, I would set up rspec-retry. Second, try this in spec/rails_helper.rb:

RSpec.configure do |config|
  config.before(:all) { visit '/' if defined?(visit) }
end
Adam Eberlin
  • 14,005
  • 5
  • 37
  • 49