@@ -421,16 +421,18 @@ describe("buildNodeServiceEnvironment", () => {
421421} ) ;
422422
423423describe ( "shared Node TLS env defaults" , ( ) => {
424+ // Pass an explicit non-nvm execPath so tests are deterministic regardless of
425+ // whether the test runner itself runs under nvm.
424426 const builders = [
425427 {
426428 name : "gateway service env" ,
427429 build : ( env : Record < string , string | undefined > , platform ?: NodeJS . Platform ) =>
428- buildServiceEnvironment ( { env, port : 18789 , platform } ) ,
430+ buildServiceEnvironment ( { env, port : 18789 , platform, execPath : "/usr/bin/node" } ) ,
429431 } ,
430432 {
431433 name : "node service env" ,
432434 build : ( env : Record < string , string | undefined > , platform ?: NodeJS . Platform ) =>
433- buildNodeServiceEnvironment ( { env, platform } ) ,
435+ buildNodeServiceEnvironment ( { env, platform, execPath : "/usr/bin/node" } ) ,
434436 } ,
435437 ] as const ;
436438
@@ -499,16 +501,25 @@ describe("resolveLinuxSystemCaBundle", () => {
499501} ) ;
500502
501503describe ( "shared Node TLS env — Linux nvm detection" , ( ) => {
504+ const nvmExecPath = "/home/user/.nvm/versions/node/v22.22.0/bin/node" ;
505+ const nonNvmExecPath = "/usr/bin/node" ;
506+
502507 const builders = [
503508 {
504509 name : "gateway service env" ,
505- build : ( env : Record < string , string | undefined > , platform ?: NodeJS . Platform ) =>
506- buildServiceEnvironment ( { env, port : 18789 , platform } ) ,
510+ build : (
511+ env : Record < string , string | undefined > ,
512+ platform ?: NodeJS . Platform ,
513+ execPath ?: string ,
514+ ) => buildServiceEnvironment ( { env, port : 18789 , platform, execPath } ) ,
507515 } ,
508516 {
509517 name : "node service env" ,
510- build : ( env : Record < string , string | undefined > , platform ?: NodeJS . Platform ) =>
511- buildNodeServiceEnvironment ( { env, platform } ) ,
518+ build : (
519+ env : Record < string , string | undefined > ,
520+ platform ?: NodeJS . Platform ,
521+ execPath ?: string ,
522+ ) => buildNodeServiceEnvironment ( { env, platform, execPath } ) ,
512523 } ,
513524 ] as const ;
514525
@@ -518,15 +529,27 @@ describe("shared Node TLS env — Linux nvm detection", () => {
518529 it . each ( builders ) (
519530 "$name defaults NODE_EXTRA_CA_CERTS on Linux when NVM_DIR is set" ,
520531 ( { build } ) => {
521- const env = build ( { HOME : "/home/user" , NVM_DIR : "/home/user/.nvm" } , "linux" ) ;
532+ const env = build (
533+ { HOME : "/home/user" , NVM_DIR : "/home/user/.nvm" } ,
534+ "linux" ,
535+ nonNvmExecPath ,
536+ ) ;
537+ expect ( env . NODE_EXTRA_CA_CERTS ) . toBe ( expectedCaBundle ) ;
538+ } ,
539+ ) ;
540+
541+ it . each ( builders ) (
542+ "$name defaults NODE_EXTRA_CA_CERTS on Linux when execPath is under nvm" ,
543+ ( { build } ) => {
544+ const env = build ( { HOME : "/home/user" } , "linux" , nvmExecPath ) ;
522545 expect ( env . NODE_EXTRA_CA_CERTS ) . toBe ( expectedCaBundle ) ;
523546 } ,
524547 ) ;
525548
526549 it . each ( builders ) (
527550 "$name does not default NODE_EXTRA_CA_CERTS on Linux without nvm" ,
528551 ( { build } ) => {
529- const env = build ( { HOME : "/home/user" } , "linux" ) ;
552+ const env = build ( { HOME : "/home/user" } , "linux" , nonNvmExecPath ) ;
530553 expect ( env . NODE_EXTRA_CA_CERTS ) . toBeUndefined ( ) ;
531554 } ,
532555 ) ;
@@ -541,6 +564,7 @@ describe("shared Node TLS env — Linux nvm detection", () => {
541564 NODE_EXTRA_CA_CERTS : "/custom/ca-bundle.crt" ,
542565 } ,
543566 "linux" ,
567+ nvmExecPath ,
544568 ) ;
545569 expect ( env . NODE_EXTRA_CA_CERTS ) . toBe ( "/custom/ca-bundle.crt" ) ;
546570 } ,
0 commit comments