Testing libraries to cover in Ember.js in Action?


#1

What test libraries would you like see covered in the book Ember.js in Action?

There is also a topic on the books forum, reply to whichever :slight_smile: http://www.manning-sandbox.com/thread.jspa?threadID=56418&tstart=0

Some alternatives for unit testing:

Is GUI Testing relative/wanted ?


Recommended Testing Solution?
#2

I’m going to suggest http://pivotal.github.com/jasmine/


#3

There is nothing or very little information on integration testing Ember.js apps. Any chance of using Konacha in the book as i have found this works very well and is very quick unlike selenium and full stack testing.


#4

Konacha seems to require a Rails driven backend application, which would make it somewhat hard to include in the book.

Unless I am missing something and it can be used stand alone :slight_smile:


#5

Perhaps you could cover cucumberjs and capybara too.


#6

@joachimhs right Konacha is rails specific.

+1 for capybara to run full-stack integration/acceptance tests. That or casper.js.


#7

@joachimhs it only requires rails as it uses the asset pipeline so can use coffeescript and different files etc.


#8

+1 for capybara since it’s basically the go-to thing for integration testing for most developers using Rails.

As for the unit testing, anything will probably work. Ember itself uses QUnit but I don’t think it matters that much.


#9

The difficulty is that integration testing is very important but there isn’t much in the way of integration testing libraries that are not dependent on the backend. The Konacha style of using an iframe that can be interacted with via jQuery is a pretty good solution, but as others have noted, it’s unfortunately coupled with Rails.


#10

I’m currently using QUnit for integration testing, running on the command line with phantom.js. I get a handle to the app’s router, then transition to the state I care about in each module. That’s my plan anyway, I’ve only written the first module so far. I like QUnit’s simplicity, and the speed with which I was able to get it working.


#11

One vote for jsKarma (formerly known as Testacular).


#12

A few of us from the OC Ember meetup group are working on experimenting writing integration tests around the Peepcode Ordr app in a repo here:

As Peter said a lot of the current testing components are being influenced by whatever backend/build system you are using.

I’m inclined to take a test runner like Testem or Karma and work towards using that for tests as its not tied to any backend. There is a split between what style of tests you like to write between qunit, jasmine, and mocha. For integration tests it seems like it really comes down to how they handle async tests. For unit tests I think the most popular has been jasmine. I think qunit has the best async support, but mocha’s async tests are the easiest to grock. Also W/ integration tests you end up fighting between your app wanting to take over the html page and your test runner creating html elements to report results as most apps I’ve seen are attached to the body element. Konacha is great as it uses an iframe to get around this, but too tied to its(rails) backend in my opinion. We have tests being run on the peepcode ordr app using two different runners (“JS Karma, Testem”). It looks like Karma already runs tests in an iframe while testem doesn’t. I’m working on pulling out the iframe runner stuff from Konacha to use it in Karma or Testem w/ a custom setup. In all of this I’d love to see more ways to be able to write integration tests that don’t use timeouts and maybe some kind of DSL to have a simple way to select and trigger input elements on a page.

Just thought I’d do a brain dump on the topic real quick.


#13

Thank you for your responses! I will look into some of these over easter and I will most likely choose one unit testing framework and one integration testing framework to cover. The ideas between most of these testing tools are fairly similar, and I only have about 25-30 pages to cover testing with Ember.js apps :slight_smile: I’d really like to cover something that uses phantom.js too though :slight_smile:


#14

I would suggest (as @andrewmp1 did) using Testem or Karma as test runners. And chose one of the libraries (jasmine, mocha or qunit). I’m using buster.js. They mainly differ in how tests are written(style).

Testem and Karma can connect to a headless browser like phantom.js. So you get what you want. And you still can test in real browsers (desktop and mobile).

I was unable to do integration tests that way (I haven’t spend too much time in it yet). So, I would be interested in @andrewmp1 findings.


#15

I’ve just posted a detailed test example in another thread using Mocha, which works great once you get it set up:

This includes model tests, view tests and integration tests using jQuery to drive the GUI.