-
Notifications
You must be signed in to change notification settings - Fork 847
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
How to test/dev with Node.js v23 #5415
Comments
Suggestions of other options are welcome. |
trentm
added a commit
to trentm/opentelemetry-js
that referenced
this issue
Feb 3, 2025
This does *not* solve testing with Node.js 23 outside of CI. Refs: open-telemetry#5415
This was referenced Feb 3, 2025
Current status:
|
Regarding option 3 - I believe the failures are related to mocking with tsx. There are a few relevant issues reported against tsx:
Those issues are about the Node test runner's mocking capabilities, but they also apply to sinon. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
the problem
Running tests with Node.js v23 (since v23.6.0) fails:
AFAICT, this is incompatible with our usage of
ts-node
to enable callingmocha
directly on the test .ts files.Generally our tests run
mocha test/**/*.test.ts
, mocha loads.mocharc.yml
which has:which basically uses
require.extensions
to tellrequire()
to handle .ts and .tsx files.My understanding is that the
experimental-strip-types
handling of .ts files take precedence.notes
I'd like to see usage of ts-node dropped eventually.
require.extensions
(the mechanism it uses) has been deprecated since Node.js v0.10.6.I'm not sure what
tsx
's mechanism is.options
option 1: compile tests to .js, run the JS files
Change all our testing to (a) first compile
test/...
then (b) executemocha 'build/test/**/*.test.js'
.Roughly that means a diff like this for each package:
However there are wrinkles:
test/**/*.ts
files tobuild/test/...
means we are executing in a different directory. References to any non-.ts files in the tests (e.g. fixtures, JSON data files, whatever), means changing those path references to "../../test/...".experimental/packages/opentelemetry-instrumentation/
the two testsnpm test
andnpm run test:browser
conflict with each other on attempting to use the recently-addedtest/common/third-party/node-semver/range-exclude.js
files.#5410 is a draft PR for this option, including showing the currently failing
npm run test:browser
inexperimental/packages/opentelemetry-instrumentation/
option 2: use
node --no-experimental-strip-types ...
There is a node option to turn off the type stripping, such that our current
ts-node
usage works.Roughly it looks like this diff in each package:
Or:
However, this breaks running with Node.js 18, 20, and older versions of Node.js v22:
We could add that option to
NODE_OPTIONS
only for Node.js 23 tests in CI.This is at best a temporary bandaid, because local dev could not be done with Node.js v23 without the developer manually setting
NODE_OPTIONS=...
.option 3: use tsx
@pichlermarc mentioned an attempt to use tsx but say "some tests are failing".
A starter diff:
I haven't dug into the test failures here.
The text was updated successfully, but these errors were encountered: