Open neokaiyuan opened 5 years ago
seems to be a broader issue with stubbing express app middleware before app gets loaded.
https://stackoverflow.com/questions/41995464/how-to-mock-middleware-in-express-to-skip-authentication-for-unit-test https://stackoverflow.com/questions/41392497/node-express-es6-sinon-stubbing-middleware-not-working https://github.com/sinonjs/sinon/issues/1711
ended up resolving this by not including ensureAuthenticated
middleware in test env, as bad as it is to include test-specific logic in production code.
seems to be a broader issue with stubbing express app middleware before app gets loaded.
https://stackoverflow.com/questions/41995464/how-to-mock-middleware-in-express-to-skip-authentication-for-unit-test https://stackoverflow.com/questions/41392497/node-express-es6-sinon-stubbing-middleware-not-working sinonjs/sinon#1711
ended up resolving this by not including
ensureAuthenticated
middleware in test env, as bad as it is to include test-specific logic in production code.
Could you provide your working example?
Expected behavior
sinon.stub(liana, 'ensureAuthenticated') should stub the ensureAuthenticated
Actual behavior
stub does not address liana 'ensureAuthenticated', and code in
forest-express-sequelize
andforest-express
seem to obscure how ensureAuthenticated is exposedContext
I use
liana.ensureAuthenticated
as a middleware as suggested by Forest docs https://doc.forestadmin.com/developer-guide/express-sequelize.html#uploading-images and am hoping to unit test my controller.