How can I stub a hasAndBelongsToMany relation with Sinon

46 views
Skip to first unread message

Bert Casier

unread,
Aug 16, 2016, 8:15:44 AM8/16/16
to StrongLoop
I have a loopback model Student, and a loopback model Teacher.
They have a hasAndBelongsToMany relation

I want to stub studentObj.teachers() in one of my tests (preferably with sinon.js)

When I try to stub it I get the following error:

Attempted to wrap undefined property teachers as function (probably because it's a getter)

I tried to stub the getter but that didn't work either
I tried to override the function but that gave me a read-only error

Is there an easy way to stub out relation methods on a Loopback modelConstructor?
Reply all
Reply to author
Forward
0 new messages