I am trying to unit-test the controllers of a Sails.js project with mocha. Since I have a different security policies I cannot use suptertest or similar testing frameworks to test the controllers, by actually calling the url. I would have to make sure the parameters of the call would pass all policies.
Instead I am trying to call the methods of the controllers directly with sails.controllers.[controller].[methods](req, res)
like suggested here, and spy on the res
object with sinon.
But whenever I call a controller method e.g. sails.controllers.booking.approve(req, res)
I get the error message TypeError: sails.controllers.booking.approve(...) is not a function
. How can I call the controller method instead?