summaryrefslogtreecommitdiff
path: root/lib/tasks/karma.rake
blob: 89812a179ecb5076696f00aa9436cfb03db0a180 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
unless Rails.env.production?
  Rake::Task['karma'].clear if Rake::Task.task_defined?('karma')

  namespace :karma do
    desc 'GitLab | Karma | Generate fixtures for JavaScript tests'
    RSpec::Core::RakeTask.new(:fixtures) do |t|
      ENV['NO_KNAPSACK'] = 'true'
      t.pattern = 'spec/javascripts/fixtures/*.rb'
      t.rspec_opts = '--format documentation'
    end

    desc 'GitLab | Karma | Run JavaScript tests'
    task :tests do
      sh "npm run karma" do |ok, res|
        abort('rake karma:tests failed') unless ok
      end
    end
  end

  desc 'GitLab | Karma | Shortcut for karma:fixtures and karma:tests'
  task :karma do
    Rake::Task['karma:fixtures'].invoke
    Rake::Task['karma:tests'].invoke
  end
end