Juan Jardim
Juan Jardim

Reputation: 2252

How can I perform unit test in ember.js ?

I've been developing a web application where I'm using ember.js 1.0. I was wondering if there is any way or framework to make unit test in ember.

For instance, suppose that I've a controller called "CustomerController" and I have a method to add need items to a shopping cart.

...
addNewItem : function(item){
    var content = shoppingCart.get("content");
    content.push(item);
    shoppingCart.set("content", content);
}
...

So i want to perform a unit test to see if the number of items increase when the customer add a new item. What kind of framework I can used to accomplish this?

Upvotes: 1

Views: 1620

Answers (2)

Dan Gebhardt
Dan Gebhardt

Reputation: 3281

Qunit works well with ember and has great async support. It's used to test ember itself.

Check out ember-app-kit, which uses qunit and the karma test runner. It includes a couple example tests, as well as some intro articles referenced in the "Getting Started" section of the README.

Upvotes: 7

Amir Hoseinian
Amir Hoseinian

Reputation: 2352

Best way for this is using Jasmine

There is a blog post explaining your answer completely here:

Unit Testing Ember.js, How I Learned to Stop Worrying and Love the Runloop

Upvotes: 2

Related Questions