Capybara:第一个测试超时 'failed to reach server, check DNS and/or server status',所有其他测试都正常

Capybara: First test times out with 'failed to reach server, check DNS and/or server status', all other tests work fine

我为 Spree/Solidus Rails 平台维护了几个扩展,并且出于某种原因在 中维护了一个扩展特别是我遇到了水豚问题,我似乎无法找到。

一旦我建立了一个测试环境,first test of the first 运行 through the specs 总是失败,with以下:

Capybara::Poltergeist::StatusFailError:
   Request to 'http://127.0.0.1:52234/products' failed to reach server,
   check DNS and/or server status - Timed out with no open resource requests

所有后续规格均通过。如果我再次 运行 bundle exec rspec spec ,那么 所有 规范都通过了。

我尝试将 Capybara 超时值增加到超高数字:

RSpec.configure do |config|
  config.include Spree::TestingSupport::CapybaraHelpers, type: :feature
  Capybara.register_driver(:poltergeist) do |app|
    Capybara::Poltergeist::Driver.new app, timeout: 90
  end
  Capybara.javascript_driver = :poltergeist
  Capybara.default_max_wait_time = 90
end

不过好像没什么效果

我所有的 Travis 构建都在第一个 运行 的第一个规范上失败(并传递其他所有内容),这使得项目难以维护,因为所有 PR 看起来都是红色的。

知道这里会发生什么吗?

当 Rails 在第一次请求时处理资产管道时,这很可能会失败。尝试在 运行 测试之前预编译测试模式资产,或者增加驱动程序注册中的超时时间。 Capybara.default_max_wait_time 根本不会影响这个。