3

I'm getting an error when using visit in a test :

TypeError: Object # has no method 'getHandler'

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

test("visit works", function () {
  expect(2);

  // this gets executed
  equal(1, 1);

  return visit("/").then(function() {
    // this doesn't
    equal(1, 1);
  });
});

The resulting error trace is :

Died on test #2     at eval (eval at <anonymous> (eval at <anonymous> (http://127.0.0.1:3000/javascripts/libs/jquery/jquery-1.8.0.min.js:2:14066)), <anonymous>:10:1)
    at eval (native)
    at eval (eval at <anonymous> (http://127.0.0.1:3000/javascripts/libs/jquery/jquery-1.8.0.min.js:2:14066), <anonymous>:2:14066)
    at Function.p.extend.globalEval (eval at <anonymous> (http://127.0.0.1:3000/javascripts/libs/jquery/jquery-1.8.0.min.js:2:14066), <anonymous>:2:14077)
    at p.ajaxSetup.converters.text script (eval at <anonymous> (http://127.0.0.1:3000/javascripts/libs/jquery/jquery-1.8.0.min.js:2:14066), <anonymous>:2:83767)
    at cC (eval at <anonymous> (http://127.0.0.1:3000/javascripts/libs/jquery/jquery-1.8.0.min.js:2:14066), <anonymous>:2:5874)
    at y (eval at <anonymous> (http://127.0.0.1:3000/javascripts/libs/jquery/jquery-1.8.0.min.js:2:14066), <anonymous>:2:79888)
    at d (eval at <anonymous> (http://127.0.0.1:3000/javascripts/libs/jquery/jquery-1.8.0.min.js:2:14066), <anonymous>:2:85578): Object #<Object> has no method 'getHandler'
Source:     
TypeError: Object #<Object> has no method 'getHandler'
    at generateHandlerInfos (eval at <anonymous> (eval at <anonymous> (http://127.0.0.1:3000/javascripts/libs/jquery/jquery-1.8.0.min.js:2:14066)), <anonymous>:25824:31)
    at performTransition (eval at <anonymous> (eval at <anonymous> (http://127.0.0.1:3000/javascripts/libs/jquery/jquery-1.8.0.min.js:2:14066)), <anonymous>:25758:30)
    at createURLTransition (eval at <anonymous> (eval at <anonymous> (http://127.0.0.1:3000/javascripts/libs/jquery/jquery-1.8.0.min.js:2:14066)), <anonymous>:25501:18)
    at doTransition (eval at <anonymous> (eval at <anonymous> (http://127.0.0.1:3000/javascripts/libs/jquery/jquery-1.8.0.min.js:2:14066)), <anonymous>:26067:20)
    at Object.Router.handleURL (eval at <anonymous> (eval at <anonymous> (http://127.0.0.1:3000/javascripts/libs/jquery/jquery-1.8.0.min.js:2:14066)), <anonymous>:25213:20)
    at Ember.Router.Ember.Object.extend._doTransition (eval at <anonymous> (eval at <anonymous> (http://127.0.0.1:3000/javascripts/libs/jquery/jquery-1.8.0.min.js:2:14066)), <anonymous>:26491:53)
    at Ember.Router.Ember.Object.extend.handleURL (eval at <anonymous> (eval at <anonymous> (http://127.0.0.1:3000/javascripts/libs/jquery/jquery-1.8.0.min.js:2:14066)), <anonymous>:26331:21)
    at Ember.Application.Ember.Namespace.extend.handleURL (eval at <anonymous> (eval at <anonymous> (http://127.0.0.1:3000/javascripts/libs/jquery/jquery-1.8.0.min.js:2:14066)), <anonymous>:30240:16)
    at Object.Backburner.run (eval at <anonymous> (eval at <anonymous> (http://127.0.0.1:3000/javascripts/libs/jquery/jquery-1.8.0.min.js:2:14066)), <anonymous>:4862:30)
    at Object.Ember.run (eval at <anonymous> (eval at <anonymous> (http://127.0.0.1:3000/javascripts/libs/jquery/jquery-1.8.0.min.js:2:14066)), <anonymous>:5200:30)

I've made sure Ember is loaded before the tests are run as suggested in this answer. QUnit is also working properly as a basic test on fixtures is working.

I've now spent hours on this issue and I don't have any clue why this is happening.

Edit (following Daniel's comment) The route is pretty simple and looks like that :

App.IndexRoute = Ember.Route.extend({
  redirect: function(){
    this.transitionTo('about');
  }
});
App.Router.map(function(){
  this.route('about');
});

Diagnosing The Situation

Perhaps you should start with diagnosing the plugins? By removing them all and adding in one by one to see what one causes an issue. As you recently updated, a plugin perhaps is causing this issue as it is outdated and is creating conflictions between the software and the extension.

The issue may be based around that the configuration cannot be found, so Joomla presumes you have not installed the software.

Have you done all of these?

  • Removed installation folder
  • Checked if .htaccess isn't causing the issue
  • Attempt a downgrade and upgrade?
4

1 回答 1

0

你应该去阅读http://emberjs.com/guides/testing/integration/

使用最新的 Ember,您无需运行App.advanceReadiness,只需App.resetteardown, 中定义任何测试套件之前,您需要调用:

App.rootElement = '#qunit-fixtures';
App.setupForTesting();
App.injectTestHelpers();

一切都应该正常工作。

让我知道遵循这个是否行不通,如果是的话,给一个我可以工作的 jsbin ;-)

编辑

此外,我不确定这会改变什么,但在他们使用的示例中,他们使用andThen的是then

visit('/');
andThen(function(){ ... });
于 2014-05-21T01:25:25.283 回答