-6ren">
gpt4 book ai didi

ember.js - Ember : Testing with Pavlov/QUnit produces TypeError: Object # has no method 'getHandler'
转载 作者:行者123 更新时间:2023-12-01 02:25:30 24 4
gpt4 key购买 nike

警告:我是新手。在此先感谢您的帮助。

Pavlov/QUnit 导致我的 ember 应用程序中的路由器出现问题。单独使用 QUnit 时,以下测试通过:

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

但是当将 Pavlov 与 QUnit 一起使用时,以下测试会失效:
describe 'contacts index', ->
it 'does render index', ->
visit('/contacts').then ->
assert(exists(".nav")).isTrue('The navbar was rendered')

并在执行以下操作时在 collectObjects 方法中产生“没有方法‘getHandler’”错误:

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



堆栈跟踪如下:
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)

最佳答案

像这样设置 Ember-testing/QUnit 测试:

App.setupForTesting();
App.injectTestHelpers();

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

当然,替换 App使用您的应用程序名称。

新款 Testing guide目前建议这样做,但不显示代码。

关于ember.js - Ember : Testing with Pavlov/QUnit produces TypeError: Object #<Object> has no method 'getHandler' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16759633/

24 4 0