-
Notifications
You must be signed in to change notification settings - Fork 1.1k
increase timeout for npm run test and factor in timezone day diff for datetimeString test
#9812
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?
Conversation
Summary of ChangesHello @aalej, 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 addresses issues encountered when running Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. 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
|
npm run test and factor in timezone day diff for datetimeString test
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 addresses failing tests by increasing the global test timeout and adjusting a date-related test to be more resilient to timezone variations. While the approach is sound, I have a couple of suggestions for improvement. The new timeout of 10 seconds seems a bit high given the test execution times mentioned, and a more conservative value might be better for catching performance regressions. Additionally, there's a minor syntax issue in the updated regular expressions for date validation that needs to be corrected.
| expect(utils.datetimeString(new Date("February 22, 2020 11:35:45-07:00"))).to.match( | ||
| /^2020-02-22 \d\d:35:45$/, | ||
| /^2020-02-2[2|3] \d\d:35:45$/, | ||
| ); | ||
| expect(utils.datetimeString(new Date("February 7, 2020 11:35:45-07:00"))).to.match( | ||
| /^2020-02-07 \d\d:35:45$/, | ||
| /^2020-02-0[7|8] \d\d:35:45$/, | ||
| ); | ||
| expect(utils.datetimeString(new Date("February 7, 2020 8:01:01-07:00"))).to.match( | ||
| /^2020-02-07 \d\d:01:01$/, | ||
| /^2020-02-0[7|8] \d\d:01:01$/, | ||
| ); |
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 regular expressions you've updated to handle timezone differences have a small syntax error. Inside a character class [], the pipe | is treated as a literal character, not an 'OR' operator.
For example, [2|3] matches the characters '2', '|', or '3', which is not the intended behavior of matching either '2' or '3'.
The correct way to specify an 'OR' condition for characters within a character class is to just list them, like [23].
I'll provide a suggestion to fix the regex patterns.
| expect(utils.datetimeString(new Date("February 22, 2020 11:35:45-07:00"))).to.match( | |
| /^2020-02-22 \d\d:35:45$/, | |
| /^2020-02-2[2|3] \d\d:35:45$/, | |
| ); | |
| expect(utils.datetimeString(new Date("February 7, 2020 11:35:45-07:00"))).to.match( | |
| /^2020-02-07 \d\d:35:45$/, | |
| /^2020-02-0[7|8] \d\d:35:45$/, | |
| ); | |
| expect(utils.datetimeString(new Date("February 7, 2020 8:01:01-07:00"))).to.match( | |
| /^2020-02-07 \d\d:01:01$/, | |
| /^2020-02-0[7|8] \d\d:01:01$/, | |
| ); | |
| expect(utils.datetimeString(new Date("February 22, 2020 11:35:45-07:00"))).to.match( | |
| /^2020-02-2[23] \d\d:35:45$/, | |
| ); | |
| expect(utils.datetimeString(new Date("February 7, 2020 11:35:45-07:00"))).to.match( | |
| /^2020-02-0[78] \d\d:35:45$/, | |
| ); | |
| expect(utils.datetimeString(new Date("February 7, 2020 8:01:01-07:00"))).to.match( | |
| /^2020-02-0[78] \d\d:01:01$/, | |
| ); |
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.
good catch! I completely forgot that regex works like that
.mocharc.yml
Outdated
| file: | ||
| - src/test/helpers/global-mock-auth.ts | ||
| timeout: 1000 | ||
| timeout: 10000 |
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.
While increasing the timeout is necessary to fix the failing tests, a 10-second timeout might be overly generous and could mask future performance regressions in the test suite. In the pull request description, you mentioned that the longest test runs in about 2 seconds and suggested that 5 seconds might be a better value. I agree with that assessment. A 5-second timeout should be sufficient to prevent timeouts due to normal fluctuations while still being tight enough to catch performance issues.
timeout: 5000There 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.
updating the timeout to 5s
|
/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 addresses test failures by increasing the Mocha timeout and making a date formatting test robust to timezone differences. The timeout increase to 5 seconds seems reasonable given the context of tests timing out at 1 second. The fix for the datetimeString test correctly handles day changes across timezones for the existing test cases. I've added one suggestion to further improve the robustness of these date-related tests by considering edge cases like month and year boundaries.
| expect(utils.datetimeString(new Date("February 22, 2020 11:35:45-07:00"))).to.match( | ||
| /^2020-02-22 \d\d:35:45$/, | ||
| /^2020-02-2[23] \d\d:35:45$/, | ||
| ); | ||
| expect(utils.datetimeString(new Date("February 7, 2020 11:35:45-07:00"))).to.match( | ||
| /^2020-02-07 \d\d:35:45$/, | ||
| /^2020-02-0[78] \d\d:35:45$/, | ||
| ); | ||
| expect(utils.datetimeString(new Date("February 7, 2020 8:01:01-07:00"))).to.match( | ||
| /^2020-02-07 \d\d:01:01$/, | ||
| /^2020-02-0[78] \d\d:01:01$/, | ||
| ); |
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.
While this change correctly fixes the test for different timezones by allowing for a day difference, it might not cover all edge cases, such as month or year boundaries. For example, a date like December 31, 2020 20:00:00Z could be 2021-01-01 in some timezones, causing both the day, month, and year to change.
To make the tests more robust, you could consider:
- Mocking the timezone for these tests (which might require an external library).
- Adding test cases for boundary conditions (e.g., end of month, end of year) to ensure
datetimeStringbehaves as expected across timezone-induced date changes.
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.
For now, for this specific test, I think we can ignore this edge case? the purpose of the test is to check if dateTimeString util will correctly format a date object into a YYYY-mm-dd HH:mm:ss format
Description
when running
npm run testa bunch of tests fail. It seems to mostly be timing out. Increasing the timeout to10s5s. Also, one test was failing because of timezone causing the day to be different by 1. The longest test ran ~2s,so maybe we could set it to 5s intead?set the timeout to 5sfailing tests with "npm run test"
Scenarios Tested
npm run testSample Commands