I'm trying to mock my sequlize db call Below is the example
it('mock db call', async() => {
sinon.stub(DBNAME, 'scope').resolves()
sinon.stub(DBNAME, 'findAll').resolves(dbDetails)
const res = await func1();
sinon.assert.match(res, dbDetails);
})
function func1
is as below
const func1 = async () => {
const getData = await DBNAME.scope(
'includeEverything',
).findAll();
return getData
}
Does anyone knows how to stub scope
and findAll
at same time.
i'm getting error as below
TypeError: models_1.DBNAME.scope(...).findAll is not a function
I'm trying to test func1 and stub 'scope' and 'findAll'.