问题
I'm getting
Uncaught TypeError: Cannot call method 'extractId' of undefined
while running integration tests with QUnit.
The failing test:
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")
Running this test in isolation works well but running this test within the module it throws the error mention above. It seems like adapterForType(App.Point) returns an undefined value.
Updating the test to
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")
mitigates the error.
The value retuned by adapterForType
in the correct test is:
Ember.inspect(this.adapterForType(App.Point))
"{serializer: <DS.FixtureSerializer:ember455>, _attributesMap: [object Object], _configurationsMap: [object Object], _outstandingOperations: [object Object], _dependencies: [object Object]}"
Any suggestion related to this behavior?
回答1:
It's possible that when running that test in isolation the adapter hasn't yet been created/initialized. Or maybe it's lazy initialized the first time the adapter has been used.
来源:https://stackoverflow.com/questions/18312596/uncaught-typeerror-cannot-call-method-extractid-of-undefined-ember-data-while