-
Notifications
You must be signed in to change notification settings - Fork 168
refactor(logger): use vitest env helpers in unit tests #4360
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
refactor(logger): use vitest env helpers in unit tests #4360
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.
Thanks for this. Added a few minor comments.
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.
Great work on this @dwrth
|
This reverts commit f9ea611.
Summary
Implements Vitest environment helpers to avoid direct manipulations on
process.env
Changes
process.env
manipulations with Vitest's environment helper functions:vi.stubEnv()
to set environment variablesvi.unstubAllEnvs()
to clear environment variablespackages/logger/tests/unit/formatters.test.ts
packages/logger/tests/unit/initializeLogger.test.ts
packages/logger/tests/unit/injectLambdaContext.test.ts
packages/logger/tests/unit/logBuffer.test.ts
packages/logger/tests/unit/logEvent.test.ts
packages/logger/tests/unit/logLevels.test.ts
const ENVIRONMENT_VARIABLES = process.env
storageafterEach
hooks withvi.unstubAllEnvs()
process.env = {...}
assignments withvi.stubEnv()
beforeEach
blocksIssue number: closes #4269
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.