red*_*r13 5 testing ember.js ember-cli
这几天来一直是个烦人的问题.当我开始尝试为我的Ember应用程序编写验收测试时,当我使用该visit()函数时,URL在浏览器的地址栏中被更改,因此当我更改一些代码并且liveReload发生时,它会导航我的测试页面到我告诉它在测试中访问的任何页面.
要进行故障排除,我ember new是一个新的应用程序,创建了一个/ home路由和模板,并为它创建了验收测试,它传递正常,而不更改地址栏中的URL.我已经比较了代码tests/helpers,它是相同的,原样tests/index.html.
我没有得到答案就搜遍了所有人.这对我来说很难进行测试,但这样的问题只是切线,但非常恼人.如果有人知道为什么会这样,我会非常感谢你的解决方案.
举个例子,这是我的一个验收测试.它通过了,但URL实际上发生了变化:
import Ember from 'ember';
import { module, test } from 'qunit';
import startApp from 'star/tests/helpers/start-app';
var application;
module('Acceptance: AddMilestone', {
beforeEach: function() {
application = startApp();
},
afterEach: function() {
Ember.run(application, 'destroy');
}
});
test('Adding milestones', function(assert)
visit('/projects/1234567/details');
andThen(function() {
assert.equal(currentPath(), 'project.details');
});
});
Run Code Online (Sandbox Code Playgroud)
寻找config/environment.js类似于此的块:
if (environment === 'test') {
// Testem prefers this...
ENV.baseURL = '/';
ENV.locationType = 'none';
// keep test console output quieter
ENV.APP.LOG_ACTIVE_GENERATION = false;
ENV.APP.LOG_VIEW_LOOKUPS = false;
ENV.APP.rootElement = '#ember-testing';
}
Run Code Online (Sandbox Code Playgroud)
是为您的环境ENV.locationType设置的?nonetest
如果没有,您是否正在更改locationType应用中的其他位置?将其设置为none单独留下地址栏.
| 归档时间: |
|
| 查看次数: |
767 次 |
| 最近记录: |