Skip to content

test(node): Ensure logs are auto-printed when a test fails#21887

Merged
mydea merged 2 commits into
developfrom
fn/auto-log-node-runners
Jul 1, 2026
Merged

test(node): Ensure logs are auto-printed when a test fails#21887
mydea merged 2 commits into
developfrom
fn/auto-log-node-runners

Conversation

@mydea

@mydea mydea commented Jul 1, 2026

Copy link
Copy Markdown
Member

We can opt-in to show sub process logs in node-integration-tests with DEBUG=1. This PR adjusts this so that we automatically show logs when a test fails. For example, in addition to this:

 FAIL  suites/express/tracing/test.ts > express tracing > should create and send transactions for Express routes and spans for middlewares. xxxx [esm]
 FAIL  suites/express/tracing/test.ts > express tracing > should create and send transactions for Express routes and spans for middlewares. xxxx [cjs]
Error: Timed out waiting for server port
 ❯ waitFor utils/runner/createRunner.ts:648:13
    646|     remaining -= 100;
    647|     if (remaining < 0) {
    648|       throw new Error(message);
       |             ^
    649|     }
    650|   }
 ❯ Object.makeRequest utils/runner/createRunner.ts:533:13

You may see:

stdout | suites/express/tracing/test.ts > express tracing > should create and send transactions for Express routes and spans for middlewares. xxxx [esm]

--- Captured child process output for /Users/francesco/git/sentry-javascript-2/dev-packages/node-integration-tests/suites/express/tracing/tmp_mr21unou_f00oan/scenario.mjs ---
file:///Users/francesco/git/sentry-javascript-2/dev-packages/node-integration-tests/suites/express/tracing/tmp_mr21unou_f00oan/instrument.mjs:5
Sentry.blasdabs();
       ^

TypeError: Sentry.blasdabs is not a function
    at file:///Users/francesco/git/sentry-javascript-2/dev-packages/node-integration-tests/suites/express/tracing/tmp_mr21unou_f00oan/instrument.mjs:5:8
    at ModuleJob.run (node:internal/modules/esm/module_job:325:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:606:24)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:112:9)

Node.js v20.19.5
--- End of captured child process output ---

Which should hopefully make it easier to figure out some test failures etc.

@mydea mydea self-assigned this Jul 1, 2026
@mydea mydea requested a review from a team as a code owner July 1, 2026 12:30
@mydea mydea requested review from JPeer264 and andreiborza and removed request for a team July 1, 2026 12:30

@JPeer264 JPeer264 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

brilliant move.

@JPeer264

JPeer264 commented Jul 1, 2026

Copy link
Copy Markdown
Member

Would be amazing if we could port this to the other runner.ts we have. I think node-core, bun and cloudflare

@mydea

mydea commented Jul 1, 2026

Copy link
Copy Markdown
Member Author

Would be amazing if we could port this to the other runner.ts we have. I think node-core, bun and cloudflare

we can look at this in a follow up I'd say!

@mydea mydea merged commit 29ed0fc into develop Jul 1, 2026
290 checks passed
@mydea mydea deleted the fn/auto-log-node-runners branch July 1, 2026 13:56
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.

3 participants