-
Notifications
You must be signed in to change notification settings - Fork 59
feat: Add tests for config feature #1407
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
base: main
Are you sure you want to change the base?
feat: Add tests for config feature #1407
Conversation
Summary of ChangesHello @MarkoMlakar, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the testing suite by introducing dedicated unit tests for the configuration feature. The primary goal is to enable faster and more efficient testing of this functionality by eliminating the dependency on Docker containers for test execution. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request adds unit tests for the config feature, which is a great step towards improving test speed and reliability by removing the Docker dependency. My review focuses on ensuring the new tests are robust and maintainable. I've identified a potential for test flakiness due to shared state and environment variable mutation, and also a small improvement for test report readability. I've provided a single suggestion that addresses these points to improve test isolation and maintainability.
6ff30c7 to
125e64e
Compare
Signed-off-by: Marko Mlakar <marko.mlakar@dynatrace.com>
* Reset env vars and state object in configSteps beforeEach for test isolation * Added better formatting for the test output Signed-off-by: Marko Mlakar <marko.mlakar@dynatrace.com>
125e64e to
dafd6ba
Compare
|
/gemini review |
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.
Code Review
This pull request introduces unit tests for the config feature, which is a valuable addition for improving test speed and developer workflow by removing the Docker dependency. The implementation is mostly sound, but I've identified a significant issue with how environment variables are managed within the tests. This could lead to test flakiness. My review comments provide detailed feedback and suggestions for creating more robust and isolated tests.
Signed-off-by: Marko Mlakar <marko.mlakar@dynatrace.com>
|
/gemini review |
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.
Code Review
This pull request introduces unit tests for the config feature, which is a great addition for improving test speed and reliability. The changes correctly set up test isolation for state and environment variables. I have a couple of suggestions to improve the robustness of the environment variable handling and to adjust the test timeout to a more conventional value for faster feedback.
…meout for the unit test Signed-off-by: Marko Mlakar <marko.mlakar@dynatrace.com>
|
/gemini review |
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.
Code Review
This pull request adds unit tests for the config feature, which is a great step towards improving test coverage and speed. The changes look good overall, but I've identified a couple of areas for improvement. There's a significant issue with test isolation due to how environment variables are being reset, which could lead to flaky tests. I've also suggested a minor improvement to make the test naming more robust by handling potential duplicate tags. Please see my detailed comments.
Signed-off-by: Marko Mlakar <marko.mlakar@dynatrace.com>
|
/gemini review |
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.
Code Review
This pull request adds unit tests for the config feature, which is a great step towards improving test speed and reliability by removing the Docker dependency. The changes in configSteps.ts to reset state and environment variables before each test are good for test isolation. I have one suggestion regarding the method used to reset process.env, proposing a more robust pattern to avoid potential brittleness in the tests.
| state.options = {}; | ||
| state.config = undefined; | ||
| state.events = []; | ||
| Object.keys(process.env).forEach((key) => delete process.env[key]); |
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.
Deleting all keys from process.env is an aggressive approach that could be brittle. For example, it might fail if the test environment sets read-only properties on process.env. A safer approach is to only remove properties that were added during the test run, which avoids wholesale deletion of all environment variables.
| Object.keys(process.env).forEach((key) => delete process.env[key]); | |
| Object.keys(process.env).filter(key => !Object.prototype.hasOwnProperty.call(originalEnv, key)).forEach(key => delete process.env[key]); |
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.
Ya I agree with this.
| events: [], | ||
| }; | ||
| autoBindSteps( | ||
| loadFeatures(CONFIG_FEATURE, { |
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.
The config.feature gherkin file is part of the in-process and rpc tests. In-Process and RPC cover all *.feature files. I don't think there is need for a specific config.spec.ts file.
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.
You are correct :) However the motivation for having a separate config.spec.ts file was to enable the test to run without requiring a container to be started
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.
this test should not be part of the e2e suite, although it uses gherkin steps, it is fast and can be run during normal unit test execution
This PR
Related Issues
Fixes #1406
How to test
Run the test suite in the
config.spec.ts