Adam Krawesky
Adam Krawesky

Reputation: 1353

how do i unit test an Ember Router?

i've looked at the unit testing for Ember.Router and noticed that it does not define any connectOutlets() on its routes.

however, i want to understand how i should unit test my own extension of the Router in my app. obviously i don't want all the dom elements instantiating for a unit test. is there a way to unit test the Router in isolation? some sort of 'headless' or 'testing' flag?

or should i just concentrate on integration testing and put my router tests in there?

 App.Router = Ember.Router.extend({})

Upvotes: 3

Views: 491

Answers (1)

Ken Browning
Ken Browning

Reputation: 29091

In a relatively recent version of Ember, a change was made to automatically initialize applications on DOM ready. As you're seeing, this can cause problems during testing. The way to opt-out of that automatic initialization is to set autoinit: false on your Ember.Application.

App = Ember.Application.create({
    autoinit: false
});

/* ... */

App.initialize();

Upvotes: 3

Related Questions