我已經設置了一個rake任務來在生成服務器上運行無頭茉莉花測試,並以junit格式輸出結果。這裏的任務:在rails中運行無頭茉莉花測試時出現錯誤
namespace :jasmine do
desc "Runs Jasmine tests headlessly and writes out junit xml."
task :headless_junit do |t, args|
run_jasmine_tests(Dir.pwd)
end
end
def run_jasmine_tests(output_dir)
require 'headless'
require 'jasmine'
require 'rspec'
require 'rspec/core/rake_task'
output_file = "#{output_dir}/jasmine_results.xml"
Headless.ly do
RSpec::Core::RakeTask.new(:jasmine_continuous_integration_runner) do |t|
t.rspec_opts = ['--format', 'RspecJunitFormatter', '--out', output_file ]
t.verbose = true
t.rspec_opts += ["-r #{File.expand_path(File.join(::Rails.root, 'config', 'environment'))}"]
t.pattern = [Jasmine.runner_filepath]
end
Rake::Task['jasmine_continuous_integration_runner'].invoke
end
end
當我運行此我得到這個錯誤:
TypeError: jasmine.getEnv(...).currentSpec is null in http://localhost:34002/assets/jquery.js?body=true (line 1129)
[email protected]://localhost:34002/assets/jquery.js?body=true:1129
@http://localhost:34002/__spec__/activity_catalog_search_filters_spec.js:15
[email protected]://localhost:34002/__jasmine__/jasmine.js:1064
[email protected]://localhost:34002/__jasmine__/jasmine.js:2096
jasmine.Queue.prototype.next_/onComplete/<@http://localhost:34002/__jasmine__/jasmine.js:2086
... LOTS MORE ...
我使用的軌道3.2.13,茉莉1.3.2,1.0.1無頭,rspec的2.14。 1和茉莉的jQuery 1.5.8
我認爲這可能是類似這樣的傢伙有問題: TypeError: jasmine.getEnv().currentSpec is null