3

I have some Angular/Rails app where Rails part is just JSON API, all front works is doing by AngularJS. I've made model/controller test already using RSpec, and now I want to make some integration tests. Earlier I use request test (with Capybara, Selenium) of RSpec to test my pages/JS, but Angular is often tested by Karma/Jasmine, and I don't understand what way is preferred in Angular/Rails app. Please, give me advice, may be you share some experience with me. Thanks.

1 Answer 1

1

First of all you should test everything wisely. I will recommend great series of blog posts from the link below.

Since you are already familiar with RSpec, keep using it for your rails tests like models, controllers, request, etc.

For your Angularjs tests, karma and Jasmine are great choices. But Rails uses Sprockets for asset management so configuring karma can be a little bit tricky. For Rails and Jasmine I wrote a rake task. To run javascript tests you should simply run rake karma:start. I shared the link of the gist below.

The gist contains 2 files. You should put them:

  • karma.rake -> lib/tasks
  • karma.unit.js -> spec/javascripts/

Finally you should run feature/acceptance tests with Capybara.

Testing Series Intro

The Gist of Rake Task and Karma Configuration

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.