# Testing libraries to cover in Ember.js in Action?

**URL:** <https://discuss.emberjs.com/t/testing-libraries-to-cover-in-ember-js-in-action/561>\
**Category:** Uncategorized\
**Created:** [March 20, 2013, 8:30am UTC](https://discuss.emberjs.com/t/testing-libraries-to-cover-in-ember-js-in-action/561 "2013-03-20T08:30:08Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![joachimhs](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/joachimhs/32/3559_2.png) [@joachimhs](https://discuss.emberjs.com/u/joachimhs)\
**Post date:** [March 20, 2013, 8:30am UTC](https://discuss.emberjs.com/t/testing-libraries-to-cover-in-ember-js-in-action/561/1 "2013-03-20T08:30:08Z")

</div>

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 🙂 [http://www.manning-sandbox.com/thread.jspa?threadID=56418&tstart=0](http://www.manning-sandbox.com/thread.jspa?threadID=56418&tstart=0)

Some alternatives for unit testing:

- Mocha ([http://visionmedia.github.com/mocha/](http://visionmedia.github.com/mocha/))
- Sinon.js ([http://sinonjs.org/](http://sinonjs.org/))
- QUnit ([http://qunitjs.com/](http://qunitjs.com/))
- Buster.js ([http://docs.busterjs.org/en/latest/](http://docs.busterjs.org/en/latest/))
- Others ?

Is GUI Testing relative/wanted ?

- Phantom.js ([http://phantomjs.org/](http://phantomjs.org/))
- WebDriver/Selenium ([http://docs.seleniumhq.org/](http://docs.seleniumhq.org/))
- Others ?

---

<div class="post-metadata">

**Author:** ![locks](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/locks/32/3878_2.png) [@locks](https://discuss.emberjs.com/u/locks)\
**Post date:** [March 20, 2013, 8:36am UTC](https://discuss.emberjs.com/t/testing-libraries-to-cover-in-ember-js-in-action/561/2 "2013-03-20T08:36:52Z")

</div>

I’m going to suggest [http://pivotal.github.com/jasmine/](http://pivotal.github.com/jasmine/)

---

<div class="post-metadata">

**Author:** ![rsmossuk](https://avatars.discourse-cdn.com/v4/letter/r/4af34b/32.png) [@rsmossuk](https://discuss.emberjs.com/u/rsmossuk)\
**Post date:** [March 20, 2013, 10:15am UTC](https://discuss.emberjs.com/t/testing-libraries-to-cover-in-ember-js-in-action/561/3 "2013-03-20T10:15:29Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![joachimhs](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/joachimhs/32/3559_2.png) [@joachimhs](https://discuss.emberjs.com/u/joachimhs)\
**Post date:** [March 20, 2013, 10:25am UTC](https://discuss.emberjs.com/t/testing-libraries-to-cover-in-ember-js-in-action/561/4 "2013-03-20T10:25:08Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![pksjce](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/pksjce/32/225_2.png) [@pksjce](https://discuss.emberjs.com/u/pksjce)\
**Post date:** [March 20, 2013, 10:30am UTC](https://discuss.emberjs.com/t/testing-libraries-to-cover-in-ember-js-in-action/561/5 "2013-03-20T10:30:12Z")

</div>

Perhaps you could cover cucumberjs and capybara too.

---

<div class="post-metadata">

**Author:** ![mikegrassotti](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/mikegrassotti/32/14281_2.png) [@mikegrassotti](https://discuss.emberjs.com/u/mikegrassotti)\
**Post date:** [March 20, 2013, 12:01pm UTC](https://discuss.emberjs.com/t/testing-libraries-to-cover-in-ember-js-in-action/561/6 "2013-03-20T12:01:02Z")

</div>

@joachimhs right Konacha is rails specific.

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

---

<div class="post-metadata">

**Author:** ![rsmossuk](https://avatars.discourse-cdn.com/v4/letter/r/4af34b/32.png) [@rsmossuk](https://discuss.emberjs.com/u/rsmossuk)\
**Post date:** [March 20, 2013, 12:41pm UTC](https://discuss.emberjs.com/t/testing-libraries-to-cover-in-ember-js-in-action/561/7 "2013-03-20T12:41:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![darthdeus](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/darthdeus/32/3609_2.png) [@darthdeus](https://discuss.emberjs.com/u/darthdeus)\
**Post date:** [March 20, 2013, 1:56pm UTC](https://discuss.emberjs.com/t/testing-libraries-to-cover-in-ember-js-in-action/561/8 "2013-03-20T13:56:49Z")

</div>

+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.

---

<div class="post-metadata">

**Author:** ![pwagenet](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/pwagenet/32/14172_2.png) [@pwagenet](https://discuss.emberjs.com/u/pwagenet)\
**Post date:** [March 20, 2013, 3:04pm UTC](https://discuss.emberjs.com/t/testing-libraries-to-cover-in-ember-js-in-action/561/9 "2013-03-20T15:04:05Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![joefiorini](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/joefiorini/32/3902_2.png) [@joefiorini](https://discuss.emberjs.com/u/joefiorini)\
**Post date:** [March 20, 2013, 3:51pm UTC](https://discuss.emberjs.com/t/testing-libraries-to-cover-in-ember-js-in-action/561/10 "2013-03-20T15:51:51Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![AdamFerguson](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/adamferguson/32/14462_2.png) [@AdamFerguson](https://discuss.emberjs.com/u/AdamFerguson)\
**Post date:** [March 20, 2013, 6:34pm UTC](https://discuss.emberjs.com/t/testing-libraries-to-cover-in-ember-js-in-action/561/11 "2013-03-20T18:34:11Z")

</div>

One vote for [jsKarma](http://karma-runner.github.com/0.8/index.html) (formerly known as Testacular).

---

<div class="post-metadata">

**Author:** ![andrewmp1](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/andrewmp1/32/14320_2.png) [@andrewmp1](https://discuss.emberjs.com/u/andrewmp1)\
**Post date:** [March 20, 2013, 8:13pm UTC](https://discuss.emberjs.com/t/testing-libraries-to-cover-in-ember-js-in-action/561/12 "2013-03-20T20:13:27Z")

</div>

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:

[https://github.com/OC-Emberjs/peepcode-ordr-test](https://github.com/OC-Emberjs/peepcode-ordr-test)

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.

---

<div class="post-metadata">

**Author:** ![joachimhs](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/joachimhs/32/3559_2.png) [@joachimhs](https://discuss.emberjs.com/u/joachimhs)\
**Post date:** [March 20, 2013, 11:23pm UTC](https://discuss.emberjs.com/t/testing-libraries-to-cover-in-ember-js-in-action/561/13 "2013-03-20T23:23:01Z")

</div>

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 🙂 I’d really like to cover something that uses phantom.js too though 🙂

---

<div class="post-metadata">

**Author:** ![guilhermeaiolfi](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/guilhermeaiolfi/32/14264_2.png) [@guilhermeaiolfi](https://discuss.emberjs.com/u/guilhermeaiolfi)\
**Post date:** [March 29, 2013, 5:16am UTC](https://discuss.emberjs.com/t/testing-libraries-to-cover-in-ember-js-in-action/561/14 "2013-03-29T05:16:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![emk](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/emk/32/14569_2.png) [@emk](https://discuss.emberjs.com/u/emk)\
**Post date:** [April 7, 2013, 4:37pm UTC](https://discuss.emberjs.com/t/testing-libraries-to-cover-in-ember-js-in-action/561/15 "2013-04-07T16:37:33Z")

</div>

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

> [@Working on a testing guide (was: detailed Ember.js testing example)](http://discuss.emberjs.com/t/detailed-ember-js-testing-example-w-mocha-feedback-welcome/887):
>
> I’ve just created a [jsFiddle with a detailed example of testing Ember.js](http://jsfiddle.net/ekidd/hCsws/13/) (latest version: [here](http://jsfiddle.net/ekidd/hCsws/)) using Mocha, Sinon, Chai and the sinon-chai and chai-jquery plugins. This shows how to test models, views and controllers, and how to do full integration tests using jQuery and chai-jquery. Why Mocha and not Jasmine? Basically, Jasmine is slightly easier to get running, but Mocha seems to be much more actively maintained, it has an excellent ecosystem, and the actual test cases look nearly the same i…

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