test(node): Migrate tracing integration tests to createEsmAndCjsTests#20961
Merged
Conversation
createEsmAndCjsTests
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 819129e. Configure here.
This reverts commit b0e762416eae75861cf619f58ad003fc473c832f.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
38ed9fc to
d348750
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Migrates the remaining integration-specific tracing tests under
dev-packages/node-integration-tests/suites/tracing/to use thecreateEsmAndCjsTestshelper, which auto-runs each scenario in both ESM and CJS mode from a single.mjssource.For each folder:
scenario*.js→scenario*.mjs(ESM imports)instrument.mjstest.tsswitched tocreateEsmAndCjsTests(__dirname, scenarioPath, instrumentPath, callback, options?)failsOnEsm: trueadded only where CJS passed and ESM legitimately fails (i.e. instrumentation only patches the CJS module shape)Migrated folders
lru-memoizerfailsOnEsm: true— OTelinstrumentation-lru-memoizeronly patches the CJS function-shaped export.mongodbimport mongodb from 'mongodb'+ destructure.mongoosemysql2mysqlfailsOnEsm: trueon all 3 scenarios — mysql v2 is CJS-only. Three scenarios kept (withConnect,withoutCallback,withoutConnect).postgresignoreConnectSpansreuses the default scenario but with a separateinstrument-ignoreConnect.mjs.pg-nativescenario migrated as-is (still relies on localsetupCommand: 'yarn'to build the native bindings).postgresjs.cjs/.mjsscenarios into a single.mjseach. Thewait-for-postgres.jshelper is still required from the scenarios viacreateRequire(import.meta.url)(revert of the .mjs-helper conversion approach — see notes below). The error stacktrace assertion usesexpect.stringMatching(/postgres(\.cjs)?\.src:connection/)so the same expectation matches both modes.redisredis-cacheioredis,redis-4). Each scenario has its owninstrument-*.mjsbecause they pass differentcachePrefixestoredisIntegration.redis-dcawait import('redis-5')insiderun()to preserve the comment-documented ordering where the DC subscriber must be registered (viaPromise.resolve().then) before node-redis eagerly creates its native TracingChannels on require/import.tediousdescribe.skip(the test was previously skipped as flaky in #15798). Manually verified both modes pass when un-skipped.apollo-graphqlapollo-server.mjshelper copied into the tmp dir viacopyPaths: ['apollo-server.mjs']and loaded withawait import('./apollo-server.mjs')from each scenario.apollo-graphql/useOperationNameForRootSpanapollo-server.mjsvia../../apollo-server.mjs(the scenarios run fromuseOperationNameForRootSpan/tmp_xxx/, so this resolves back to the apollo-graphql folder). Scenarios useSentry.getClient().tracerinstead of capturing the client returned bySentry.init(since init now lives ininstrument.mjs).Out of scope
The following folders under
tracing/are still usingcreateRunnerdirectly — they are not integrations for a specific package but general tracing-behavior tests, so they're intentionally left alone:meta-tags*,meta-tags-twp*sample-rate-propagation/*,sample-rand-propagationtracePropagationTargets/*traceid-recycling*dsc-txn-name-updatehttp-client-spans/*maxSpans,envelope-header/*,linking🤖 Generated with Claude Code