Ember.js 在测试ember组件集成测试时终止服务

Ember.js 在测试ember组件集成测试时终止服务,ember.js,ember-cli,ember-testing,Ember.js,Ember Cli,Ember Testing,我正在看《灰烬测试指南》,上面说,当您想要删除服务时,请执行以下操作 import { moduleForComponent, test } from 'ember-qunit'; import hbs from 'htmlbars-inline-precompile'; import Ember from 'ember'; //Stub location service const locationStub = Ember.Service.extend({ city: 'New York

我正在看《灰烬测试指南》,上面说,当您想要删除服务时,请执行以下操作

import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
import Ember from 'ember';

//Stub location service
const locationStub = Ember.Service.extend({
  city: 'New York',
  country: 'USA',
  currentLocation: {
    x: 1234,
    y: 5678
  },

  getCurrentCity() {
    return this.get('city');
  },
  getCurrentCountry() {
    return this.get('country');
  }
});

moduleForComponent('location-indicator', 'Integration | Component | location indicator', {
  integration: true,

  beforeEach: function () {
    this.register('service:location-service', locationStub);
    this.inject.service('location-service', { as: 'location' });
  }
});
问题是我得到了一个
未捕获类型错误:当我使用此代码时,this.register不是一个函数。因此,我假设在每个
this.register('service:location service',locationStub')之前都有是导致问题的原因


任何人都知道我如何解决这个问题,或者什么是删除服务的更合适的方法?此代码当前位于Ember的文档中。

看起来像这样。注册表仅在Ember qunit的更高版本上存在,您需要确保运行的Ember qunit>=0.4.13

此.register仅在ember qunit>=0.4.13时存在