Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ember.js/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ember.js 在Ember验收测试中的测试上下文之外调用stop()_Ember.js_Qunit_Acceptance Testing_Ember Qunit - Fatal编程技术网

Ember.js 在Ember验收测试中的测试上下文之外调用stop()

Ember.js 在Ember验收测试中的测试上下文之外调用stop(),ember.js,qunit,acceptance-testing,ember-qunit,Ember.js,Qunit,Acceptance Testing,Ember Qunit,我用Ember CLI进行了第一次验收测试。我使用Ember Mirage模拟服务器 test('create file', function(assert){ visit('/login'); fillIn('input[name=username]', 'Joe'); fillIn('input[name=password]', 'foo'); click('button'); andThen(function() { visit(

我用Ember CLI进行了第一次验收测试。我使用Ember Mirage模拟服务器

  test('create file', function(assert){
    visit('/login');
    fillIn('input[name=username]', 'Joe');
    fillIn('input[name=password]', 'foo');
    click('button');

    andThen(function() { 
      visit('/projects/files');
    });

    andThen(function(){
      assert.ok(true);
    })  
  });
测试成功运行,但挂起,我得到以下错误

未捕获(承诺中)错误:在测试上下文之外调用stop()

在Object.stop()处 在Class.asyncStart()上 在异步开始时()在 位于的Object.async() 履行 handleMaybeThenable() at resolve()at sealed ()

Ajax服务

我使用ajax服务,它调用自定义api端点。正如您所看到的,它使用标准的JSONAPISerializer。可能还是个问题?这是一个现有的应用程序,没有它就无法轻松地关闭此服务和进行测试

export default Ember.Service.extend({
  // http://stackoverflow.com/questions/9705773/non-crud-actions-with-ember-data
  call: function(method, type, id, action, hash = null){
    var owner = Ember.getOwner(this);
    var adapter = owner.lookup('adapter:application');
    var url = adapter.buildURL(type, id) + '/' + action;
    if (hash) {
      hash.data = $.extend({}, hash);
    }
    return adapter.ajax(url, method, hash);

  }
});
编辑1

我稍微更改了测试,并打开了ENV.APP.LOG\u TRANSITIONS\u INTERNALENV.APP.LOG\u TRANSITIONS,以查看发生了什么:

$.Velocity.mock = true
var done = assert.async();
visit('/login');
fillIn('input[name=username]', 'Joe');
fillIn('input[name=password]', 'foo');
click('button');

andThen(function() { 
  visit('/projects/files/new/overview');
  setTimeout(function() {
    assert.equal( find('.btn-primary').length, 2,"button was found" );
    done();
  }, 20000);
});
看来登录工作正常

转换#2:projects.files.new.overview.index:调用反序列化 hook-ember.debug.js:51061转换#2: projects.files.new.overview.index:调用afterModel挂钩 ember.debug.js:51061转换#2:解析了目标上的所有模型 路线;完成过渡。ember.debug.js:6520生成-> 控制器:项目对象{fullName:“控制器:项目”}

告诉我,转换还可以,我可以在qunit的容器中看到新页面

有时我也会收到

未捕获错误:断言失败:您已打开测试模式, 它禁用了运行循环的自动运行。您将需要包装任何代码 在运行中产生异步副作用


我认为您需要使用QUnit的异步功能@杰克:谢谢。你能提供更多的信息吗?我应该在setTimeout中设置x ms直到/projects/files的html出现吗?您是否有预感,为什么会发生这种情况?此错误:“未捕获错误:断言失败:您已打开测试模式,该模式禁用了运行循环的自动运行。您需要在运行中包装具有异步副作用的任何代码”可能是因为您使用的是
setTimeout
,使用
Ember.run.later
instead@awpeter我已经搜索了我的应用程序文件夹,但代码中没有setTimeout。你在EDIT1代码中有它,这就是我所指的,我认为你需要使用QUnit的异步功能@杰克:谢谢。你能提供更多的信息吗?我应该在setTimeout中设置x ms直到/projects/files的html出现吗?您是否有预感,为什么会发生这种情况?此错误:“未捕获错误:断言失败:您已打开测试模式,该模式禁用了运行循环的自动运行。您需要在运行中包装具有异步副作用的任何代码”可能是因为您使用的是
setTimeout
,使用
Ember.run.later
instead@awpeter我已经搜索了我的应用程序文件夹,但代码中没有setTimeout。EDIT1代码中有setTimeout,这就是我所指的