Skip to content

Conversation

@zahin-mohammad
Copy link
Contributor

@zahin-mohammad zahin-mohammad commented Aug 21, 2025

This PR moves our test runners from ts-node to tsx to resolve some issues introduced between ts-node and node 22.18.0.

Details here

Given ts-node is no longer maintained, we are transitioning to TSX.

Due to TSX running tests in ESM mode, opposed to how ts-node ran tests in commonJS mode, a lot of imports and stubbing behaviour had to be fixed.

This does not change the compiled javascript behaviour.

Prior Art

Related Issues

TICKET: WP-5599

@zahin-mohammad zahin-mohammad force-pushed the WP-5599/fix-node-22-ci-2 branch 2 times, most recently from d89b0f0 to cffe130 Compare August 21, 2025 14:47
ts-node is no longer maintained, and as such
introduces friction with newer versions of nodejs.
[Example](nodejs/node#59364)
This commit moves to an actively maintained alternative.

TICKET: WP-5599

TICKET: WP-5599
Replace "*" imports with specific imports from
assert module. When upgrading the test runner
from ts-node to tsx, we need to fix imports to
be strictly ESM to avoid:
"TypeError: assert is not a function"

TICKET: WP-5599

TICKET: WP-5599
The import of `create-hmac` was changed from
an ES module import to a CommonJS.
This is required for compatibility with both tsx and Node.js 22.

TICKET: WP-5599

TICKET: WP-5599
Fix circular reference issues in Dimensions class by moving static property initializations
outside the class definition. This ensures compatibility with tsx and Node.js 22, which
enforce stricter ESM module loading rules than ts-node with older Node versions.

TICKET: WP-5599

TICKET: WP-5599
🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

TICKET: WP-5599
🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

TICKET: WP-5599
Modified sinon stubbing approach to work with ESM modules by using
require() and monkey patching instead of direct imports, which allows
tests to function correctly after migrating from ts-node to tsx.

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

Co-Authored-By: Claude <noreply@anthropic.com>

TICKET: WP-5599
🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

TICKET: WP-5599
Replace sinon.stub() with proxyquire for mocking clientRoutes module imports.
This fixes tests now that we use tsx which runs in ESM mode - ES modules are
immutable and cannot be modified at runtime, preventing sinon from stubbing
them. Proxyquire works by intercepting module resolution at the CommonJS level.

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

Co-Authored-By: Claude <noreply@anthropic.com>

TICKET: WP-5599
@zahin-mohammad zahin-mohammad force-pushed the WP-5599/fix-node-22-ci-2 branch from 0ca2729 to 8883cf0 Compare August 21, 2025 22:58
@zahin-mohammad zahin-mohammad changed the title feat: update nvmrc fix: update tests for node 22.18.0 Aug 21, 2025
@zahin-mohammad zahin-mohammad force-pushed the WP-5599/fix-node-22-ci-2 branch from 7b24de9 to cf375c7 Compare August 22, 2025 00:45
@zahin-mohammad zahin-mohammad marked this pull request as ready for review August 22, 2025 01:10
@zahin-mohammad zahin-mohammad requested review from a team as code owners August 22, 2025 01:10
@zahin-mohammad
Copy link
Contributor Author

Audit issues will be addressed separately

@zahin-mohammad zahin-mohammad merged commit 603ab36 into master Aug 22, 2025
11 of 12 checks passed
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.

5 participants