What is the preferred method for testing an Angular / Rails application?

I have an Angular / Rails application where the Rails part is just JSON API, all the front-end work is done by AngularJS. I have already tested the model / controller using RSpec and now I want to do some integration tests. I used to use a request test (with Capybara, Selenium) RSpec to test my pages / JS, but Angular is often tested by Karma / Jasmine and I don't understand which path is preferred in Angular / Rails application. Please give me some advice, maybe you can share your experience with me. Thank you.

+3


source to share


1 answer


First of all, you must check everything thoroughly. I will recommend a large series of blog posts from the link below.

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

For your Angularjs tests, karma and jasmine are great choices. But Rails uses Sprockets for asset management, so setting up karma can be a little tricky. For Rails and Jasmine, I wrote a rake. To run javascript tests, you should simply run rake karma:start

. I have shared the link below.

The essence contains 2 files. You have to put them:



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

Finally, you must test drive the Capybara.

Intro Series Testing

Rake task challenge and karma settings

+1


source







All Articles