我有一个大型测试套件,使用了poltergeist和capybara.我一直收到以下错误:
One or more errors were raised in the Javascript code on the page. If you don't care about
these errors, you can ignore them by setting js_errors: false in your Poltergeist
configuration (see documentation for details).
Run Code Online (Sandbox Code Playgroud)
我很确定我已经设置了js_errors:false但我仍然得到错误.我意识到最佳解决方案是修复JS但我继承遗留代码并修复错误超出了我的角色范围.我的规范帮助文件如下所示:
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'capybara/poltergeist'
Capybara.javascript_driver = :poltergeist
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(app, {js_errors: false})
end
Capybara.current_driver = :poltergeist
Capybara.configure do |config|
config.match = :one
config.exact_options = true
config.ignore_hidden_elements = true
config.visible_text_only = true
end …Run Code Online (Sandbox Code Playgroud) 我已经设置了VCR,并且可以在我编写的无问题的多个测试上运行。我尝试写入的最新测试将在首次运行时通过,但在此之后仍将失败,除非删除卡带。该测试的代码是:
it "doesn't blow up if a user doesn't have billing info" do
VCR.use_cassette('tax_reconciler/no_method_error')do
user_guid = rand(10000000)
CreateRecurlyTestData.create_account(user_guid, nil, nil)
tax_reconciler = TaxReconciler.new
new_tax_amount = rand(100000)
user = create_test_user(:guid => user_guid)
expect(tax_reconciler.update_tax_amount(user, new_tax_amount)).to_not raise_error
end
end
Run Code Online (Sandbox Code Playgroud)
错误消息如下:
失败/错误:CreateRecurlyTestData.create_account(user_guid,nil,nil)VCR ::错误:: UnhandledHTTPRequestError:
================================================================================
An HTTP request has been made that VCR does not know how to handle:
GET https://2b64d08ef45c446dbba75720a37b7d41:@api.recurly.com/v2/accounts/3276643
VCR is currently using the following cassette:
- /Users/Evan/dish/stallone/fixtures/vcr_cassettes/tax_reconciler/no_method_error.yml
- :record => :once
- :match_requests_on => [:method, :uri]
Under the current configuration VCR …Run Code Online (Sandbox Code Playgroud)