-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(logger): disable logs while testing with jest --silent in dev env #1165
feat(logger): disable logs while testing with jest --silent in dev env #1165
Conversation
Also I think it could be interesting to surface this new behavior in the docs, specifically in this section. We could add a new sub section under Testing your code |
… also suppresses logs (aws-powertools#1165)
What about testing? Is there a way to unit test this "silent" behavior? I only came up with the idea to somehow check what type of |
Co-authored-by: Andrea Amorosi <dreamorosi@gmail.com>
I don't think we should test Jest's behavior. From my point of view we just need to test that when |
This is what I meant actually. I tested the global node object when
@dreamorosi what do you think? |
I think that's acceptable, maybe just leave a comment right above the assertion for future reference to explain the assertion. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I wasn't 100% clear with my previous comment.
In the changes related to the docs, could we please add a code snippet that shows how to call jest with the flag & with the environment variable, similar to what done here?
i.e.
export POWERTOOLS_DEV=true && npx jest --silent
I missed the comment it happens in remote communication. I'm pleased to finish the job appropriately. Let me know if some other changes are needed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @shdq!
Tomorrow morning I will test the code locally (same process as the one in the issue) & see how it renders in the documentation - then if it's all good I'll approve & we can merge :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @shdq, I have reviewed the code and it looks good. I also have tested this version in a separate codebase & verified that the `--silent- flag is indeed respected.
I'm going to run the integration tests on this branch now.
In the meanwhile I have left a comment/question about one of the sections of your changes.
Co-authored-by: Andrea Amorosi <dreamorosi@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Integration tests are passing: https://github.com/awslabs/aws-lambda-powertools-typescript/actions/runs/3469565442
@shdq thank you so much for all the hard work here!
Description of your changes
It conditionally initializes console property as an instance of the internal version of Console() class (PR #748) or as the global node console if the `POWERTOOLS_DEV' env variable is set and has a truthy value.
How to verify this change
Related issues, RFCs
Issue number:
#1030
PR status
Is this ready for review?: YES
Is it a breaking change?: NO
Checklist
Breaking change checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.