我已经设置了一个 rake 任务来在构建服务器上运行无头 jasmine 测试并以 junit 格式输出结果。这是任务:
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)
expect@http://localhost:34002/assets/jquery.js?body=true:1129
@http://localhost:34002/__spec__/activity_catalog_search_filters_spec.js:15
jasmine.Block.prototype.execute@http://localhost:34002/__jasmine__/jasmine.js:1064
jasmine.Queue.prototype.next_@http://localhost:34002/__jasmine__/jasmine.js:2096
jasmine.Queue.prototype.next_/onComplete/<@http://localhost:34002/__jasmine__/jasmine.js:2086
... LOTS MORE ...
我正在使用 rails 3.2.13、jasmine 1.3.2、headless 1.0.1、rspec 2.14.1 和 Jasmine-jQuery 1.5.8
我认为这可能类似于这个人遇到的问题: TypeError: jasmine.getEnv().currentSpec is null