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')
});
asked Sep 22, 2021 at 12:44

1 Answer 1

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();
answered Sep 22, 2021 at 20:52
Sign up to request clarification or add additional context in comments.

1 Comment

How to do that using Jest framework?

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.