我正在尝试整合烬-cli-海市蜃楼固定在一些测试。我在这里跟踪了文档:余烬固定装置
问题:未定义服务器。错误消息:ReferenceError: server is not defined
模型-test.js:
import { moduleForModel, test } from 'ember-qunit';
moduleForModel('network', 'Unit | Model | network', {
needs: []
});
test('it exists', function(assert) {
server.loadFixtures('networks'); //no defined
andThen(function() {
let net1 = networks.first();
});
assert.ok(true);
});我还验证了配置设置为true。
ENV['ember-cli-mirage'] = {
enabled: true
}发布于 2016-07-27 20:42:27
幻影在初始化器中启动。由于初始化器只在整个Ember应用程序启动时才运行,因此默认情况下,幻影服务器只能在验收测试中使用。
要在集成或单元测试中使用幻影,请遵循手动启动幻影服务器的文档。目前,医生们说:
要在单元测试或集成测试期间运行幻影服务器,首先创建一个助手: // test/helpers/start-mirage.js从‘.././初始化器/成员-cli-海市蜃楼’导入mirageInitializer;导出默认函数startMirage(容器){mirageInitializer.initialize(容器)}; 然后,在您希望幻影初始化的任何测试中添加以下内容: //测试/集成/组件/您的-test.js从‘../helpers/start-mirage’导入startMirage;moduleForComponent(‘your component’、‘’、{ integration: true、setup: function() { startMirage(this.container);}};
https://stackoverflow.com/questions/38622153
复制相似问题