在最近将Ember CLI从2.15.0迁移到3.7.0之后,验收测试出现了严重的倒退。运行qunit codemod后,以下问题似乎仍然存在:UnrecognizedURLError: /tests。
我已经通过以下验收测试生成了该问题的最小复制品:
import { module, test } from 'qunit';
import { visit, currentURL } from '@ember/test-helpers';
import { setupApplicationTest } from 'ember-qunit';
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
module('Acceptance | poc', function(hooks) {
setupApplicationTest(hooks);
setupMirage(hooks);
test('visiting /poc', async function(assert) {
await visit('/');
assert.equal(currentURL(), '/');
});
});这会导致以下三个问题:
Promise rejected before "visiting /poc": /tests?filter=poc
Source: UnrecognizedURLError: /tests?filter=poc beforeEach failed on visiting /poc: You must call one of the ember-qunit setupTest(), setupRenderingTest() or setupApplicationTest() methods before calling setupMirage()
Source: Error: You must call one of the ember-qunit setupTest(), setupRenderingTest() or setupApplicationTest() methods before calling setupMirage()Promise rejected after "visiting /poc": Cannot use 'in' operator to search for 'destroy' in undefined@ 80 ms
Source: TypeError: Cannot use 'in' operator to search for 'destroy' in undefined任何建议都将不胜感激!
发布于 2019-03-29 07:10:59
正如@jelhan在上面的评论中指出的,这里的问题是environment.js配置中缺少test环境设置。
为了修复UnrecognizedURLError,添加ENV.locationType = 'none'满足了测试的要求。
我还替换了链接的block中的其他环境变量。
我的测试环境配置现在如下所示:
else if(environment === 'test') {
ENV.locationType = 'none';
ENV.APP.LOG_ACTIVE_GENERATION = false;
ENV.APP.LOG_VIEW_LOOKUPS = false;
ENV.APP.rootElement = '#ember-testing';
ENV.APP.autoboot = false;
}https://stackoverflow.com/questions/55292104
复制相似问题