简体   繁体   中英

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({})

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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM