Closed pstoica closed 11 years ago
Thanks for the link, will definitely look at it. Angular seems like a cool tool so it's always nice to learn something I'm completely unfamiliar with.
Jonathan
On Jun 5, 2013, at 7:39 AM, Al Snow notifications@github.com wrote:
— Reply to this email directly or view it on GitHub.
If y'all have any questions about how things are setup, just let me know! I'll run through and clean up a few things soon.
Suggest setting this up even if you don't use it right away. Here is the short version:
I just set this up at my work so I'll get this set up pretty quickly. Only concern is that I don't think it would be wise to use cucumber for integration testing since you would have to tell the browser to wait (a couple of seconds) on every AJAX request, or hook into the JS to find out how many pending requests there are, and I don't feel these integration test suites were designed for that. Angular provides a testing suite that takes care of these concerns, but it's easier to use mocked JSON data as opposed to the real API (especially when database cleaning and factory_girl come in). Is mock data acceptable? Any other ideas? There's not a lot of information on how people approach this issue with end-to-end tests.
I would encourage you to move your concern into a separate issue so to focus this issue on "Angular testing with Jasmine/Karma".
I mean, this is questioning the need/usefulness for Cucumber/Capybara when Karma/Jasmine/Angular were designed to handle testing on their own. This isn't a separate issue, I need to understand how I'm setting up the testing framework.
+1 for mocking the data / unit testing the frontend. Full request specs are just too slow to TDD against. The only concern then is that your mocks get out of sync with what the controllers are sending back - which is where Travis running the full Cucumber suite helps - but I think having unit tests on the front end is valuable in and of itself.
Agreed, I'll keep looking to see if there's some way to wait for all pending requests on Cucumber's side.
Just turned off all of the cucumber tests for now. Will decide later on the future of these and other cucumber tests.
I did some more research and Karma would be the wrong tool since we're depending on Rails's asset pipeline. The other thing is that real integration tests would use a real database, which needs to be in a known state--and there's no way to do that in Angular E2E tests without mocking (or Karma where multiple browsers can run the app asynchronously), while RSpec and Cucumber cover the whole spectrum fine, even if it might be slower. Capybara (with WebDriver, PhantomJS, or some other JS-enabled adapter) looks like it should be able to automatically handle asynchronous javascript by waiting and trying again if elements don't exist. I haven't tried it out yet, but I'm hoping it works for our purposes.
So I'll use Jasminerice to write unit tests with the asset pipeline intact, and Cucumber should hopefully be fine for integration tests.
I saw this one in 24pullrequests repo: http://www.solitr.com/blog/2012/04/konacha-tutorial-javascript-testing-with-rails/
Looks like that'll serve the same purpose as Jasminerice (using mocha instead of jasmine), but I think E2E/integration would still have to be through Cucumber/RSpec. Let me know if you have a preference between Jasminerice and Konacha.
You pick and I will support.
sample app: https://github.com/angular/angular-seed
My favorite article so far: http://www.yearofmoo.com/2013/01/full-spectrum-testing-with-angularjs-and-testacular.html
Lots of code examples.
This will be impacted by railsify effort.
If by "impacted" you mean "obviated" ...
Unfortunately didn't get to do any client-side testing, so it'd be reassuring to focus on that (and do some refactoring too) for the next round and integrate it with CI.