# test/karma.conf.js
...
basePath: '<%= Bundler.root %>',
...
files: [
'<%= resolve_asset('vis.js') %>',
'app/assets/javascripts/app.js',
'test/**/*_spec.js'
],
# Rakefile
namespace :test do
task js: :environment do
with_tmp_karma_config do |config|
sh "./node_modules/karma/bin/karma start #{config} --single-run"
end
end
private
def with_tmp_karma_config
Tempfile.open('karma.js') do |f|
f.write ERB.new(File.read('test/karma.conf.js')).result(binding)
f.flush
yield f.path
end
end
def resolve_asset(file)
Rails.application.assets.find_asset(file).to_a.first.pathname.to_s
end
end
Like this:
Like Loading...
Related