Skip to content

Split Test changes out of Mcollina's PR into separate sections#737

Closed
jdmarshall wants to merge 5 commits into
prometheus:masterfrom
jdmarshall:mcollinaTests
Closed

Split Test changes out of Mcollina's PR into separate sections#737
jdmarshall wants to merge 5 commits into
prometheus:masterfrom
jdmarshall:mcollinaTests

Conversation

@jdmarshall

Copy link
Copy Markdown
Contributor

Matteo filed a ginormous PR - #727 - that modified 61 files. It has problems on top of that.

  • it conflicts with two separate PRs of mine that had already merged
  • He used Claude to migrate the unit tests
    • They have merge conflicts with tests I added
    • They rely on features of Node >=22 that eslint is now flagging as hard errors
    • He accidentally removed code coverage
  • He introduced two benchmarking tools that overlap partially with faceoff
  • He introduced dependencies that were in low single digit version numbers

I am splitting this PR into smaller PRs while preserving attribution. The tests are likely the largest PR and also break compatibility and that's why the tests are all red. This will probably need to go into the backlog until May when Node 20 reaches End of Life. I'm less concerned about how awful this is or is not to maintain in the interim as I am about removing its noise from the performance changes. I'm not a huge fan of node assert, but I'm not in a spot to introduce chai expect to clean up this code.

But it might be best to revisit this next summer.

jdmarshall and others added 5 commits January 2, 2026 16:07
It is very difficult to work on new functionality if the tests won't
even run while you are mid-refactor, and running the linter first
means any change to argument count can result in needing linefeeds
or needing to remove them in order to run the tests.
Prep work for Matteo's commits.
- Replace Jest with node:test for all 26 test files
- Add @sinonjs/fake-timers for timer mocking functionality
- Remove Jest snapshots in favor of explicit error messages
- Create test/helpers.js with describeEach and timer utilities
- Update package.json test commands for node:test compatibility
- Convert all Jest assertions to assert module patterns
- Handle module mocking limitations with custom solutions
- Remove Jest artifacts and __snapshots__ directory
- Update CLAUDE.md documentation with new test commands
- Fix ESLint configuration to support node:test features

Test Results: 511/518 tests passing (98.6% success rate)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

Edited by Jason Marshall <[email protected]>
Fixed several test failures that occurred during the migration from Jest
to node:test in registerTest.js:

1. Updated 'should throw if created with an unsupported type' test to
   expect TypeError instead of Error, matching the actual implementation
   in lib/registry.js where the constructor throws TypeError for invalid
   content types.

2. Replaced fragile JSON.stringify() comparisons with assert.deepStrictEqual()
   in three "should not throw with default labels" tests (counter, gauge,
   histogram). The JSON.stringify approach was failing due to property order
   differences, while deepStrictEqual properly compares object structure
   regardless of property order.

All 518 tests now pass successfully.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
The processOpenFileDescriptors test was failing on macOS because the Jest
to node:test migration in commit 2cf3295 lost the platform mocking that
made the test pass on all platforms.

The original Jest test used jest.mock to fake process.platform as 'linux',
but node:test doesn't have equivalent mocking capabilities. Since the metric
implementation correctly returns early on non-Linux platforms, the test
should skip on non-Linux systems rather than fail.

This change:
- Adds { skip: !isLinux } to the test to properly skip it on non-Linux
- Disables n/no-unsupported-features/node-builtins for test files to allow
  use of node:test features

Fixes test regression from commit 2cf3295.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
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.

2 participants