Skip to content

[Test] Add unit tests for js/utils/performanceTracker.js #6458

@eyeaadil

Description

@eyeaadil

What needs testing

js/utils/performanceTracker.js needs test coverage. It is a utility for performance instrumentation, but currently has no associated tests in the repository.

Current coverage

Current test coverage for this file is 0% (there is no test file).

Proposed approach

I propose creating js/utils/tests/performanceTracker.test.js using the Jest framework to write a comprehensive test suite. The approach will cover:

  • Toggling the enabled/disabled state (enable(), disable(), isEnabled()).
  • Verifying the "no-op" behavior of tracking methods when the tracker is disabled.
  • Testing the timing functions (startRun(), endRun(), getStats(), reset()).
  • Testing depth tracking via enterBlock() and exitBlock(), including edge cases.
  • Verifying console output logging logic fallback behavior.
  • Verifying memory tracking gracefully handles missing performance.memory support in environments like jsdom.

Checklist

  • I have read and followed the project's code of conduct.
  • I have checked that no existing tests cover this area.
  • I have checked that there is no open PR for the tests I am submitting.
  • I have reviewed docs/TESTING.md for testing patterns.

📚 See Testing Guide for how to write block tests.

🙋🙋 Questions: Community Matrix Server.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions