Ember 集成测试模拟转换到另一条路线然后返回
Ember Integration test simulate transition to another route and then back
我先解释一下这个问题:
我们有一个基于 Ember 的脏表单检查器,如果用户转换到另一个页面并在页面上有更改时确认转换,它应该重置 isDirty 标志。我们有一个错误,如果用户通过更改进行转换,确认更改,然后返回,不做任何更改并再次导航离开,确认对话框再次出现。简单修复,只需在初始确认时重置标志。现在,我正在尝试为此编写一个集成测试,但我找不到关于如何测试它的明确文档。我想做的是以编程方式改变形式,过渡离开,然后返回,然后再次离开。我怎样才能做到这一点?这是 Ember 2.3.0.
这是我试过的方法:
this.render(hbs `{{#mycomp invokeDialog=invokeDialog on-dirty=formDirtyEvent on-confirm=dialogConfirmEvent on-cancel=dialogCancelEvent}}
{{mytextfield id=id label="dummy-form-fullName" type="text" inputBindValue="Paul Ryan"}}
{{/mycomp}}`);
Ember.$("#textfield-" + this.get('id')).val("Paul Ryana");
fillIn(Ember.$('#textfield-' + this.get('id')), 'Paul Ryanna');
visit("/").then(function() {
});
这会生成 错误:
"Error: Assertion Failed: You cannot use the same root element
(#ember-testing) multiple times in an Ember.Application"
您应该使用 acceptance tests for transitioning between routes. Integration tests (component tests) 仅用于独立于应用程序流程测试组件功能。所以你得到这个错误是因为实际上没有你可以访问的路线。
我先解释一下这个问题: 我们有一个基于 Ember 的脏表单检查器,如果用户转换到另一个页面并在页面上有更改时确认转换,它应该重置 isDirty 标志。我们有一个错误,如果用户通过更改进行转换,确认更改,然后返回,不做任何更改并再次导航离开,确认对话框再次出现。简单修复,只需在初始确认时重置标志。现在,我正在尝试为此编写一个集成测试,但我找不到关于如何测试它的明确文档。我想做的是以编程方式改变形式,过渡离开,然后返回,然后再次离开。我怎样才能做到这一点?这是 Ember 2.3.0.
这是我试过的方法:
this.render(hbs `{{#mycomp invokeDialog=invokeDialog on-dirty=formDirtyEvent on-confirm=dialogConfirmEvent on-cancel=dialogCancelEvent}}
{{mytextfield id=id label="dummy-form-fullName" type="text" inputBindValue="Paul Ryan"}}
{{/mycomp}}`);
Ember.$("#textfield-" + this.get('id')).val("Paul Ryana");
fillIn(Ember.$('#textfield-' + this.get('id')), 'Paul Ryanna');
visit("/").then(function() {
});
这会生成 错误:
"Error: Assertion Failed: You cannot use the same root element (#ember-testing) multiple times in an Ember.Application"
您应该使用 acceptance tests for transitioning between routes. Integration tests (component tests) 仅用于独立于应用程序流程测试组件功能。所以你得到这个错误是因为实际上没有你可以访问的路线。