我越来越
Uncaught TypeError: Cannot call method 'extractId' of undefined
使用 QUnit 运行集成测试时。
失败的测试:
module "Points",
setup: ->
App.reset()
Ember.run App, App.advanceReadiness
test "Index", ->
visit("/points").then ->
ok(exists(".title:contains('POINTS')"), "Retrieved title of points section")
App.Point.find().then (points) ->
equal(find(".listContainer li").length, points.get('length') , "Retrieved correct number of points")
单独运行此测试效果很好,但在模块内运行此测试会引发上述错误。
这好像是adapterForType(App.Point) https://github.com/emberjs/data/blob/master/packages/ember-data/lib/system/store.js#L1678返回未定义的值。
将测试更新为
test "Index", ->
result = App.Point.find()
visit("/points").then ->
ok(exists(".title:contains('POINTS')"), "Retrieved title of points section")
result.then (points) ->
equal(find(".listContainer li").length, points.get('length') , "Retrieved correct number of points")
减轻误差。
返回值由adapterForType
正确的测试是:
Ember.inspect(this.adapterForType(App.Point))
"{serializer: <DS.FixtureSerializer:ember455>, _attributesMap: [object Object], _configurationsMap: [object Object], _outstandingOperations: [object Object], _dependencies: [object Object]}"
有与此行为相关的建议吗?