현재 웹 사이트에서 EmberJS 공식 자습서를 실행 중이며 this part입니다. ember serve
을 실행할 때 모든 것이 앱 자체에서 완벽하게 작동하지만 문제는 새로운 서비스에 대한 단위 테스트를 실행할 때입니다. 나는 ember test --server
를 실행하고 그리고 내가 아래의 스크린 샷했습니다 오류 얻을 :Ember JS 튜토리얼 : TypeError : 정의되지 않은 'maps'속성을 읽을 수 없습니다.
단위 테스트 코드 : 튜토리얼에서
import { moduleFor, test } from 'ember-qunit';
import Ember from 'ember';
const DUMMY_ELEMENT = {};
let MapUtilStub = Ember.Object.extend({
createMap(element, location) {
this.assert.ok(element, 'createMap called with element');
this.assert.ok(location, 'createMap called with location');
return DUMMY_ELEMENT;
}
});
moduleFor('service:maps', 'Unit | Service | maps', {
needs: ['util:google-maps']
});
test('should create a new map if one isnt cached for location', function (assert) {
assert.expect(4);
let stubMapUtil = MapUtilStub.create({ assert });
let mapService = this.subject({ mapUtil: stubMapUtil });
let element = mapService.getMapElement('San Francisco');
assert.ok(element, 'element exists');
assert.equal(element.className, 'map', 'element has class name of map');
});
test('should use existing map if one is cached for location', function (assert) {
assert.expect(1);
let stubCachedMaps = Ember.Object.create({
sanFrancisco: DUMMY_ELEMENT
});
let mapService = this.subject({ cachedMaps: stubCachedMaps });
let element = mapService.getMapElement('San Francisco');
assert.equal(element, DUMMY_ELEMENT, 'element fetched from cache');
});
, 내 이해입니다 this.subject({ cachedMaps: stubCachedMaps })
가 설정됩니다 모든 maps
나를 위해하지만 서비스 자체가 정의되지 않을 수도 있습니다, 아무 속성으로 이어질 maps
. 이게 옳은 거니? 무엇이 이것을 일으킬 수 있습니까? ember --version
실행에서
시스템 사양 :
- 엠버-CLI : 2.13.0
- 노드 : 6.8.1
- OS : 다윈 64
예, 그렇습니다. 나는 내가 정신병자라고 생각해서 코드 복사를 시작했다. 이것은 깨졌습니다. 아무도 대답하지 않을 때까지 기다려야합니다 – codyc4321