简体   繁体   中英

Testing Rails app with RSpec and Capybara

In testing my rails app (using RSpec and Capybara) I am having troubles testing AngularJS functions (from the Users point of view). Can I not test with only RSpec and Capybara or do I also need something like protractor?

any help would be great! thank you!

You could test with Capybara, so long as you use a driver that supports javascript, such as Selenium or Poltergeist - see https://github.com/jnicklas/capybara#drivers

However, although I'm not an AngularJS user, I do know that it's designed to be testable, and I imagine you'd be much better off using a tool specifically for javascript testing, rather than capybara.

As long as angular provides it's own methods and functionalities you should separate the testing suite into two. The first one, rspec, capybara and rails will be testing just the non-angular pages.

Second one, using a tool like jasmine should be testing the angular behaviour. Both combined provides good coverage of the application.

https://docs.angularjs.org/guide/unit-testing

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM