Skip to content

test(node): Migrate tracing integration tests to createEsmAndCjsTests#20961

Merged
mydea merged 16 commits into
developfrom
fn/rewrite-node-integration-tests
May 18, 2026
Merged

test(node): Migrate tracing integration tests to createEsmAndCjsTests#20961
mydea merged 16 commits into
developfrom
fn/rewrite-node-integration-tests

Conversation

@mydea
Copy link
Copy Markdown
Member

@mydea mydea commented May 18, 2026

Summary

Migrates the remaining integration-specific tracing tests under dev-packages/node-integration-tests/suites/tracing/ to use the createEsmAndCjsTests helper, which auto-runs each scenario in both ESM and CJS mode from a single .mjs source.

For each folder:

  • scenario*.jsscenario*.mjs (ESM imports)
  • Sentry.init extracted into a separate instrument.mjs
  • test.ts switched to createEsmAndCjsTests(__dirname, scenarioPath, instrumentPath, callback, options?)
  • failsOnEsm: true added only where CJS passed and ESM legitimately fails (i.e. instrumentation only patches the CJS module shape)

Migrated folders

Folder Notes
lru-memoizer failsOnEsm: true — OTel instrumentation-lru-memoizer only patches the CJS function-shaped export.
mongodb mongodb v3 is CJS-only and has no named ESM exports — uses import mongodb from 'mongodb' + destructure.
mongoose Straight migration.
mysql2 Straight migration (docker).
mysql failsOnEsm: true on all 3 scenarios — mysql v2 is CJS-only. Three scenarios kept (withConnect, withoutCallback, withoutConnect).
postgres 3 scenarios. ignoreConnectSpans reuses the default scenario but with a separate instrument-ignoreConnect.mjs. pg-native scenario migrated as-is (still relies on local setupCommand: 'yarn' to build the native bindings).
postgresjs Consolidated previously-parallel .cjs/.mjs scenarios into a single .mjs each. The wait-for-postgres.js helper is still required from the scenarios via createRequire(import.meta.url) (revert of the .mjs-helper conversion approach — see notes below). The error stacktrace assertion uses expect.stringMatching(/postgres(\.cjs)?\.src:connection/) so the same expectation matches both modes.
redis Straight migration (docker).
redis-cache 2 scenarios (ioredis, redis-4). Each scenario has its own instrument-*.mjs because they pass different cachePrefixes to redisIntegration.
redis-dc Uses await import('redis-5') inside run() to preserve the comment-documented ordering where the DC subscriber must be registered (via Promise.resolve().then) before node-redis eagerly creates its native TracingChannels on require/import.
tedious Migrated but kept describe.skip (the test was previously skipped as flaky in #15798). Manually verified both modes pass when un-skipped.
apollo-graphql 3 scenarios (query, mutation, error). Shared apollo-server.mjs helper copied into the tmp dir via copyPaths: ['apollo-server.mjs'] and loaded with await import('./apollo-server.mjs') from each scenario.
apollo-graphql/useOperationNameForRootSpan 6 scenarios. Reuses the parent apollo-server.mjs via ../../apollo-server.mjs (the scenarios run from useOperationNameForRootSpan/tmp_xxx/, so this resolves back to the apollo-graphql folder). Scenarios use Sentry.getClient().tracer instead of capturing the client returned by Sentry.init (since init now lives in instrument.mjs).

Out of scope

The following folders under tracing/ are still using createRunner directly — 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-propagation
  • tracePropagationTargets/*
  • traceid-recycling*
  • dsc-txn-name-update
  • http-client-spans/*
  • maxSpans, envelope-header/*, linking

🤖 Generated with Claude Code

@mydea mydea changed the title test(node-integration): Migrate tracing integration tests to createEsmAndCjsTests test(node): Migrate tracing integration tests to createEsmAndCjsTests May 18, 2026
@mydea mydea changed the title test(node): Migrate tracing integration tests to createEsmAndCjsTests test(node): Migrate tracing integration tests to createEsmAndCjsTests May 18, 2026
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread dev-packages/node-integration-tests/suites/tracing/postgres/test.ts Outdated
@mydea mydea self-assigned this May 18, 2026
@mydea mydea marked this pull request as ready for review May 18, 2026 09:16
@mydea mydea requested a review from a team as a code owner May 18, 2026 09:16
Copy link
Copy Markdown
Member

@JPeer264 JPeer264 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

@mydea mydea force-pushed the fn/rewrite-node-integration-tests branch from 38ed9fc to d348750 Compare May 18, 2026 10:06
@mydea mydea merged commit aa5f78a into develop May 18, 2026
47 checks passed
@mydea mydea deleted the fn/rewrite-node-integration-tests branch May 18, 2026 10:23
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