Currently, I am utilizing loopback in conjunction with express session to store cartId.
However, for the purpose of making my tests function properly, it is essential that I inject cartId into the request session.
Within my remote method, I have implemented:
Cart.get = function (req, cb) {
Service.getCart(req, req.session.cartId)
.then(function (result) {
cb(null, result);
})
.catch(cb);
};
Cart.remoteMethod(
'get',
{
accepts: { arg: 'req', type: 'object', 'http': { source: 'req' } },
returns: { arg: 'cart', type: 'object', root: true },
http: { path: '/', verb: 'get' }
}
);
I am seeking a way to enforce req.session.cartId for my tests. Any insights on this matter would be greatly appreciated.
Thank you.