I was just wondering how others approach testing their ember apps when using ember-rails. I could write integration tests using Capybara with a headless webkit javascript driver like poltergeist. Ember App Kit uses Qunit + Ember Testing + Testem. I’m not sure if testing ember was intentionally omitted from the design of ember-rails. It seems strange that figuring out how to test ember applications with ember-rails is ambiguous since rails developers have a strong heritage of testing. Since ember-rails has generators for everything else, I would think that those generators would also generate accompanying tests as rails generators do.
Any suggestions would be welcome. I am just about at the point of forking ember-rails and writing some QUnit generators to try to match what ember app kit uses.
I’ve just released a book today on the subject of Ember.js and testing with Rails.
You may find that useful.
I took the approach of using Teaspoon and QUint as I find it better to test My Ember code natively rather that driving it via Capybara. I also found it a bit difficult to work with the Ember run loop with Capybara which made testing in isolation difficult.
Martin, thank you for that book. I just bought it. I am up to page 25, and so far the book is pure gold. I’m definitely going to take the approach of using teaspoon + QUnit for my testing.
I must admit that I feel a bit guilty. I’ve been underwhelmed with books I have purchased on leanpub in the past, so I only paid the minimum. Your book is a quick read at 63 pages (so far), but the content I’ve read so far is fantastic.
Martin, does your book explain how to setup tests with the ember-cli style of apps with ES6 modules? I’m currently struggling with that and would happily buy your book if that’s the case.
@charles_demers, no, sorry, Ember CLI didn’t exist when I started writing. Because it’s aimed at Rails applications, we use Rails infrastructure to do all the heavy lifting.
Martin, that looks like an awesome book! I couldn’t see any direct mention of this on the product page - does your book cover Ember Data or are you using a different data library or a custom approach?
Hi @lookingsideways, yes Ember data is used for persistence management and does include relationships.
I’ve been on a bit of a pause recently as I’m swamped with other work, so haven’t updated it in a month or so. There are currently some issues relating to mocking HTTP requests (the library ‘fakehr’ doesn’t work since Ember 1.4) and the use of the Teaspoon gem (need to use specific version).
I’m coding along with your book and on page 90 when I include the turnOnRESTAdapter function in the setup as described the tests just freeze. I guess that’s related to ‘fakehr’ not working?
[quote=“mfeckie, post:10, topic:4162, full:true”]
Oh! Well thanks for that. I hope you find it useful and give me a yell if you need anything clarified.
[/quote] - I bought the book and am enjoying going through it so far - is there a code repo (or even a zip file like the Pragmatic series uses) that customers have access to? If not, I think this might be a helpful accompaniment to the book.
@mfeckie - done, though I sent the message to you on another discourse powered forum (after a bit of Internet searching) due to this one not having private message buttons enabled on your profile…hope that’s ok and not alarming, I really wanted the code lol