我越来越
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)
返回一个未定义的值。
将测试更新为
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]}"
与此行为有关的任何建议?