Skip to content

chore: add telemetry unit tests #109

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

Merged
merged 3 commits into from
Apr 28, 2025
Merged

chore: add telemetry unit tests #109

merged 3 commits into from
Apr 28, 2025

Conversation

blva
Copy link
Collaborator

@blva blva commented Apr 24, 2025

No description provided.

@coveralls
Copy link
Collaborator

coveralls commented Apr 24, 2025

Pull Request Test Coverage Report for Build 14672206053

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+2.7%) to 85.154%

Totals Coverage Status
Change from base Build 14671868948: 2.7%
Covered Lines: 771
Relevant Lines: 859

💛 - Coveralls

@blva blva marked this pull request as ready for review April 25, 2025 20:01
@blva blva requested review from fmenezes and Copilot April 25, 2025 20:01
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds unit tests for telemetry functionalities to ensure correct event emission behaviors under various conditions.

  • Introduces tests for sending events and caching on failures when telemetry is enabled.
  • Adds tests to verify no events are sent when telemetry is disabled or DO_NOT_TRACK is enabled.
  • Verifies that common telemetry properties are correctly attached to events.

@blva blva requested a review from a team as a code owner April 25, 2025 22:51
Copy link
Collaborator

@gagik gagik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice; just a question I'm wondering about


beforeEach(() => {
// Reset mocks before each test
jest.clearAllMocks();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not too familiar with jest but since the original file mock happens in the global scope and doesn't get re-run; doesn't that imply this should clear that as well?
I assume this works I'm just trying to understand if jest doesn't clear file mocks here or something

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep thanks for the question, the global scope ones guarantee that we won't use the actual implementation while the clear will simply clean up any leftover state between runs

@blva blva merged commit b7a25a9 into main Apr 28, 2025
16 checks passed
@blva blva deleted the telemetry-2 branch April 28, 2025 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants