Emberjs: Testing with Pavlov / QUnit creates a TypeError: Object # <Object> does not have a getHandler 'method

Warning: I am new. Thanks in advance for any help.

Pavlov / QUnit is causing problems with the router in my ember application. Using only QUnit passes the following test:

test "/contacts", -> expect(1) visit('/contacts').then -> ok(exists(".nav"), "The navbar was rendered") 

But when using Pavlov with QUnit, the following test dies:

 describe 'contacts index', -> it 'does render index', -> visit('/contacts').then -> assert(exists(".nav")).isTrue('The navbar was rendered') 

and throws a getHandler error "without the getHandler method" in the collectObjects method when the following is true:

var handler = router.getHandler (result.handler);

Stack trace below:

 TypeError: Object #<Object> has no method 'getHandler' at collectObjects (http://localhost:3000/assets/test_helper.js:37674:28) at Object.Router.handleURL (http://localhost:3000/assets/test_helper.js:37347:9) at Ember.Router.Ember.Object.extend.handleURL (http://localhost:3000/assets/test_helper.js:38135:17) at Ember.Application.Ember.Namespace.extend.handleURL (http://localhost:3000/assets/test_helper.js:41451:12) at http://localhost:3000/assets/test_helper.js:18367:19 at Object.Ember.handleErrors (http://localhost:3000/assets/test_helper.js:14228:17) at invoke (http://localhost:3000/assets/test_helper.js:18365:16) at Object.tryable (http://localhost:3000/assets/test_helper.js:18550:14) at Object.Ember.tryFinally (http://localhost:3000/assets/test_helper.js:15023:24) at Object.Ember.run (http://localhost:3000/assets/test_helper.js:18554:16) 
+4
source share
2 answers

I had the same problem with QUnit. Tests started before my Ember app was ready, so visit() calls failed.

Try turning the QUnit autorun flag on to false ( http://api.qunitjs.com/QUnit.config/ ) and call QUnit.start() from the application callback. This fixed it for me, if you need more help, you can look at this repo: https://github.com/remichaignon/ember-boilerplate

0
source

Configure the Ember-testing / QUnit tests as follows:

 App.setupForTesting(); App.injectTestHelpers(); module("Integration Tests", { setup: function() { App.reset(); Ember.run(App, App.advanceReadiness); } }); 

Of course, replace the App with your application name.

The new Test Guide currently offers this, but does not show code.

+3
source

Source: https://habr.com/ru/post/1482821/


All Articles