-
Notifications
You must be signed in to change notification settings - Fork 146
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
test(logger): simplify unit tests structure #2942
Conversation
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.
Hello @dreamorosi! Just a few comments that don't impact the tests, but make it easier to read and understand.
APPROVED!
Quality Gate passedIssues Measures |
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.
APPROVED!
Summary
Changes
This PR aims at improving maintainability and lower the barrier of entry for working on the unit tests for the Logger feature.
Before working on this PR we had 310 unit test cases, many of which redundant, and most importantly the majority of the tests were organised in a single big file (
Logger.test.ts
) which after 3 yrs of work had grown to over 3K LOC.As primary objective, the PR breaks down the big test file in smaller and more focused files. As a secondary objective, the PR also in many cases changed the test strategy to prioritize observing side effects (i.e. the log output) versus testing the internals of the Logger or its implementation details.
The result of this work is a new test suite with ~130 test cases and the same coverage level that is instead more interested in asserting that the logger actually logs things in the expect way rather than how its internals work.
With this new testing strategy, we are also enabling
POWERTOOLS_DEV
by default for all tests except one, which allows us to put spies on the global console object, and remove the behavior described in #2821.In future PRs, once we have migrated this module to Vitest, I'll continue investing some time in further improving the tests by creating custom assertions that will allow us to cut even more boilerplate from the tests.
Issue number: #2821
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.