0

I am facing issue in testing where My logger is in lambda layer thus non-existing for nodeJs import in lambda.js during mocha-chai testing. I tried mock-fs but getting errors Can not find module /opt/logger.js or maybe I am trying wrong way and not sure if it is useful in this way. Please check below code for reference. Any help or suggestion is most welcome.

lambda.js -

const logger = require('/opt/logger.js') // coming from lambda_layer.js

lambda.test.js -

mock({
    "/opt/logger.js": console.log('hello')
});
Vishvendra Singh
  • 484
  • 5
  • 19

1 Answers1

0

Was able to accomplish this with mockery. Thanks for allowing me to put this here for everyone. Will update this with better code soon.

mockery.registerMock({'/test/': { destroyAllHumans: actionStub })
mockery.enabled();
Vishvendra Singh
  • 484
  • 5
  • 19