Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.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 用于在应用程序路由中呈现模式的Qunit_Ember.js_Ember Cli_Qunit_Ember Router_Ember Qunit - Fatal编程技术网

Ember.js 用于在应用程序路由中呈现模式的Qunit

Ember.js 用于在应用程序路由中呈现模式的Qunit,ember.js,ember-cli,qunit,ember-router,ember-qunit,Ember.js,Ember Cli,Qunit,Ember Router,Ember Qunit,在我的申请过程中,我从ember网站上获得了关于如何呈现modals的打开和关闭的代码。 我一直在寻找如何对渲染操作进行单元测试的示例,但找不到太多文档 在我对应用程序路由的单元测试中,只是为了触发路由上的操作并查看会发生什么,这就是我所拥有的和我得到的错误。感谢您提供的任何指导 test('route open modal', function(assert) { let route = this.subject(); route.send('openModal', 'cancel-

在我的申请过程中,我从ember网站上获得了关于如何呈现modals的打开和关闭的代码。

我一直在寻找如何对渲染操作进行单元测试的示例,但找不到太多文档

在我对应用程序路由的单元测试中,只是为了触发路由上的操作并查看会发生什么,这就是我所拥有的和我得到的错误。感谢您提供的任何指导

test('route open modal', function(assert) {
  let route = this.subject();
  route.send('openModal', 'cancel-modal');
  assert.ok(route);
});


Died on test #1     at Module.callback (http://localhost:4200/exampleApp/assets/tests.js:1113:24)
    at Module.exports (http://localhost:4200/exampleApp/assets/vendor.js:140:32)
    at requireModule (http://localhost:4200/exampleApp/assets/vendor.js:32:18)
    at TestLoader.require (http://localhost:4200/exampleApp/assets/test-support.js:7124:7)
    at TestLoader.loadModules (http://localhost:4200/exampleApp/assets/test-support.js:7116:14)
    at Function.TestLoader.load (http://localhost:4200/exampleApp/assets/test-support.js:7146:22)
    at http://localhost:4200/exampleApp/assets/test-support.js:7030:18: Cannot read property 'state' of undefined@ 31 ms
Source:     
TypeError: Cannot read property 'state' of undefined
    at parentRoute (http://localhost:4200/exampleApp/assets/vendor.js:41309:64)
    at buildRenderOptions (http://localhost:4200/exampleApp/assets/vendor.js:41371:27)
    at Class.render (http://localhost:4200/exampleApp/assets/vendor.js:41191:27)
    at Class.openModal (http://localhost:4200/exampleApp/assets/exampleApp.js:1118:14)
    at Class.send (http://localhost:4200/exampleApp/assets/vendor.js:40471:39)
    at Class.superWrapper [as send] (http://localhost:4200/exampleApp/assets/vendor.js:54491:22)
    at Object.<anonymous> (http://localhost:4200/exampleApp/assets/tests.js:1115:11)
    at runTest (http://localhost:4200/exampleApp/assets/test-support.js:3471:30)
    at Test.run (http://localhost:4200/exampleApp/assets/test-support.js:3457:6
测试('route open model',函数(assert){
让route=this.subject();
route.send('openmodel','cancel model');
assert.ok(路由);
});
在Module.callback的测试#1中死亡(http://localhost:4200/exampleApp/assets/tests.js:1113:24)
at Module.exports(http://localhost:4200/exampleApp/assets/vendor.js:140:32)
按要求(http://localhost:4200/exampleApp/assets/vendor.js:32:18)
在TestLoader.require(http://localhost:4200/exampleApp/assets/test-support.js:7124:7)
在TestLoader.loadModules上(http://localhost:4200/exampleApp/assets/test-support.js:7116:14)
在Function.TestLoader.load(http://localhost:4200/exampleApp/assets/test-support.js:7146:22)
在http://localhost:4200/exampleApp/assets/test-support.js:7030:18:无法读取未定义@31 ms的属性“state”
资料来源:
TypeError:无法读取未定义的属性“状态”
在父母之路(http://localhost:4200/exampleApp/assets/vendor.js:41309:64)
在建筑渲染时(http://localhost:4200/exampleApp/assets/vendor.js:41371:27)
在课堂上(http://localhost:4200/exampleApp/assets/vendor.js:41191:27)
在Class.openModal(http://localhost:4200/exampleApp/assets/exampleApp.js:1118:14)
在课堂上,发送(http://localhost:4200/exampleApp/assets/vendor.js:40471:39)
在Class.superWrapper[作为发送](http://localhost:4200/exampleApp/assets/vendor.js:54491:22)
反对。(http://localhost:4200/exampleApp/assets/tests.js:1115:11)
运行测试时(http://localhost:4200/exampleApp/assets/test-support.js:3471:30)
在测试运行时(http://localhost:4200/exampleApp/assets/test-support.js:3457:6
两件事

  • 您使用的是过时的解决方案。您链接到的文档页已存在两年

    取而代之的是,在模态对话框中使用一个现代的插件。我个人更喜欢,但也有

  • 您正在尝试呈现某些内容时使用单元测试。单元测试用于运行方法并检查其返回值。若要测试呈现的模式对话框,您需要接受测试

  • test('route open modal', function(assert) {
      let route = this.subject();
      route.send('openModal', 'cancel-modal');
      assert.ok(route);
    });
    
    
    Died on test #1     at Module.callback (http://localhost:4200/exampleApp/assets/tests.js:1113:24)
        at Module.exports (http://localhost:4200/exampleApp/assets/vendor.js:140:32)
        at requireModule (http://localhost:4200/exampleApp/assets/vendor.js:32:18)
        at TestLoader.require (http://localhost:4200/exampleApp/assets/test-support.js:7124:7)
        at TestLoader.loadModules (http://localhost:4200/exampleApp/assets/test-support.js:7116:14)
        at Function.TestLoader.load (http://localhost:4200/exampleApp/assets/test-support.js:7146:22)
        at http://localhost:4200/exampleApp/assets/test-support.js:7030:18: Cannot read property 'state' of undefined@ 31 ms
    Source:     
    TypeError: Cannot read property 'state' of undefined
        at parentRoute (http://localhost:4200/exampleApp/assets/vendor.js:41309:64)
        at buildRenderOptions (http://localhost:4200/exampleApp/assets/vendor.js:41371:27)
        at Class.render (http://localhost:4200/exampleApp/assets/vendor.js:41191:27)
        at Class.openModal (http://localhost:4200/exampleApp/assets/exampleApp.js:1118:14)
        at Class.send (http://localhost:4200/exampleApp/assets/vendor.js:40471:39)
        at Class.superWrapper [as send] (http://localhost:4200/exampleApp/assets/vendor.js:54491:22)
        at Object.<anonymous> (http://localhost:4200/exampleApp/assets/tests.js:1115:11)
        at runTest (http://localhost:4200/exampleApp/assets/test-support.js:3471:30)
        at Test.run (http://localhost:4200/exampleApp/assets/test-support.js:3457:6