cli icon indicating copy to clipboard operation
cli copied to clipboard

test: try waiting for log and otherwise timeout

Open khendrikse opened this issue 2 months ago โ€ข 1 comments

๐ŸŽ‰ Thanks for submitting a pull request! ๐ŸŽ‰

Summary

  • Replace arbitrary pause() delays with event-based waitForLogMatching() in integration tests to reduce flakiness
  • Enhance waitForLogMatching() to check existing output buffer before listening for future events
  • Add configurable timeout parameter with clear error messages when events don't occur

Details Problem: Tests used await pause(TIME) to wait for file watcher events. This is flaky because:

  • On slow machines, 500ms might not be enough
  • On fast machines, we wait longer than necessary
  • No feedback when something actually goes wrong

Solution: Replace blind delays with waitForLogMatching() which:

  • Resolves immediately when the expected log message appears
  • Uses the original timeout as a maximum wait time (safety net)
  • Throws a clear error if the event never happens

For us to review and ship your PR efficiently, please perform the following steps:

  • [ ] Open a bug/issue before writing your code ๐Ÿง‘โ€๐Ÿ’ป. This ensures we can discuss the changes and get feedback from everyone that should be involved. If you`re fixing a typo or something that`s on fire ๐Ÿ”ฅ (e.g. incident related), you can skip this step.
  • [ ] Read the contribution guidelines ๐Ÿ“–. This ensures your code follows our style guide and passes our tests.
  • [ ] Update or add tests (if any source code was changed or added) ๐Ÿงช
  • [ ] Update or add documentation (if features were changed or added) ๐Ÿ“
  • [ ] Make sure the status checks below are successful โœ…

A picture of a cute animal (not mandatory, but encouraged)

khendrikse avatar Dec 04 '25 13:12 khendrikse

๐Ÿ“Š Benchmark results

Comparing with beee1443c8bed59aa7d0ae381e4f299f8e8b70d7

  • Dependency count: 1,044 (no change)
  • Package size: 304 MB โฌ†๏ธ 0.00% increase vs. beee1443c8bed59aa7d0ae381e4f299f8e8b70d7
  • Number of ts-expect-error directives: 378 (no change)

github-actions[bot] avatar Dec 04 '25 13:12 github-actions[bot]