99import { MockTraceEventFileSink } from '../../../mocks/sink.mock' ;
1010import { subscribeProcessExit } from '../exit-process.js' ;
1111import type { PerformanceEntryEncoder } from '../performance-observer.js' ;
12+ import { ID_PATTERNS } from '../process-id.js' ;
1213import type {
1314 ActionTrackEntryPayload ,
1415 UserTimingDetail ,
@@ -33,10 +34,6 @@ const simpleEncoder: PerformanceEntryEncoder<{ message: string }> = entry => {
3334 return [ ] ;
3435} ;
3536
36- // ─────────────────────────────────────────────────────────────
37- // Helper functions
38- // ─────────────────────────────────────────────────────────────
39-
4037const resetEnv = ( ) => {
4138 // eslint-disable-next-line functional/immutable-data
4239 delete process . env . DEBUG ;
@@ -192,7 +189,6 @@ describe('NodejsProfiler', () => {
192189 it ( 'should initialize with sink opened when enabled is true' , ( ) => {
193190 const profiler = createProfiler ( {
194191 measureName : 'init-enabled' ,
195- enabled : true ,
196192 } ) ;
197193 expect ( profiler . state ) . toBe ( 'running' ) ;
198194 expect ( profiler . stats . shardOpen ) . toBe ( true ) ;
@@ -322,7 +318,6 @@ describe('NodejsProfiler', () => {
322318 it ( 'is idempotent for repeated operations' , ( ) => {
323319 const profiler = createProfiler ( {
324320 measureName : 'idempotent-operations' ,
325- enabled : true ,
326321 } ) ;
327322
328323 profiler . setEnabled ( true ) ;
@@ -359,7 +354,6 @@ describe('NodejsProfiler', () => {
359354 it ( 'should expose shardPath in stats' , ( ) => {
360355 const profiler = createProfiler ( {
361356 measureName : 'filepath-getter' ,
362- enabled : true ,
363357 } ) ;
364358 // When measureName is provided, it's used as the groupId directory
365359 expect ( profiler . stats . shardPath ) . toContain (
@@ -395,7 +389,6 @@ describe('NodejsProfiler', () => {
395389 it ( 'should perform measurements when enabled' , ( ) => {
396390 const profiler = createProfiler ( {
397391 measureName : 'measurements-enabled' ,
398- enabled : true ,
399392 } ) ;
400393
401394 const result = profiler . measure ( 'test-op' , ( ) => 'success' ) ;
@@ -424,7 +417,9 @@ describe('NodejsProfiler', () => {
424417 const stats = profiler . stats ;
425418 // shardPath uses dynamic shard ID format, so we check it matches the pattern
426419 expect ( stats . shardPath ) . toMatch (
427- / ^ t m p \/ p r o f i l e s \/ s t a t s - g e t t e r \/ t r a c e \. \d { 8 } - \d { 6 } - \d { 3 } \. \d + \. \d + \. \d + \. j s o n l $ / ,
420+ new RegExp (
421+ `^tmp/profiles/stats-getter/trace\\.${ ID_PATTERNS . INSTANCE_ID . source } \\.jsonl$` ,
422+ ) ,
428423 ) ;
429424 expect ( stats ) . toStrictEqual ( {
430425 profilerState : 'idle' ,
@@ -454,15 +449,13 @@ describe('NodejsProfiler', () => {
454449 it ( 'flush() should flush when profiler is running' , ( ) => {
455450 const profiler = createProfiler ( {
456451 measureName : 'flush-running' ,
457- enabled : true ,
458452 } ) ;
459453 expect ( ( ) => profiler . flush ( ) ) . not . toThrow ( ) ;
460454 } ) ;
461455
462456 it ( 'should propagate errors from measure work function' , ( ) => {
463457 const profiler = createProfiler ( {
464458 measureName : 'measure-error' ,
465- enabled : true ,
466459 } ) ;
467460
468461 const error = new Error ( 'Test error' ) ;
@@ -476,7 +469,6 @@ describe('NodejsProfiler', () => {
476469 it ( 'should propagate errors from measureAsync work function' , async ( ) => {
477470 const profiler = createProfiler ( {
478471 measureName : 'measure-async-error' ,
479- enabled : true ,
480472 } ) ;
481473
482474 const error = new Error ( 'Async test error' ) ;
@@ -605,7 +597,6 @@ describe('NodejsProfiler', () => {
605597 process . env . DEBUG = 'true' ;
606598 const profiler = createProfiler ( {
607599 measureName : 'debug-no-transition-marker' ,
608- enabled : true ,
609600 } ) ;
610601
611602 performance . clearMarks ( ) ;
@@ -683,7 +674,6 @@ describe('NodejsProfiler', () => {
683674 it ( 'setEnabled toggles profiler state' , ( ) => {
684675 const profiler = createSimpleProfiler ( {
685676 measureName : 'exit-set-enabled' ,
686- enabled : true ,
687677 } ) ;
688678 expect ( profiler . isEnabled ( ) ) . toBe ( true ) ;
689679
@@ -699,7 +689,6 @@ describe('NodejsProfiler', () => {
699689 expect ( ( ) =>
700690 createSimpleProfiler ( {
701691 measureName : 'exit-uncaught-exception' ,
702- enabled : true ,
703692 } ) ,
704693 ) . not . toThrow ( ) ;
705694
@@ -731,7 +720,6 @@ describe('NodejsProfiler', () => {
731720 const handlers = captureExitHandlers ( ) ;
732721 const profiler = createSimpleProfiler ( {
733722 measureName : 'exit-unhandled-rejection' ,
734- enabled : true ,
735723 } ) ;
736724 expect ( profiler . isEnabled ( ) ) . toBe ( true ) ;
737725
@@ -762,7 +750,6 @@ describe('NodejsProfiler', () => {
762750 const handlers = captureExitHandlers ( ) ;
763751 const profiler = createSimpleProfiler ( {
764752 measureName : 'exit-handler-shutdown' ,
765- enabled : true ,
766753 } ) ;
767754 const closeSpy = vi . spyOn ( profiler , 'close' ) ;
768755 expect ( profiler . isEnabled ( ) ) . toBe ( true ) ;
0 commit comments