11import { performance } from 'node:perf_hooks' ;
22import { beforeEach , describe , expect , it , vi } from 'vitest' ;
3- import { awaitObserverCallbackAndFlush } from '@code-pushup/test-utils' ;
3+ import {
4+ awaitObserverCallbackAndFlush ,
5+ osAgnosticPath ,
6+ } from '@code-pushup/test-utils' ;
47import {
58 loadAndOmitTraceJson ,
69 loadAndOmitTraceJsonl ,
@@ -360,7 +363,7 @@ describe('NodejsProfiler', () => {
360363 measureName : 'filepath-getter' ,
361364 } ) ;
362365 // When measureName is provided, it's used as the groupId directory
363- expect ( profiler . stats . shardPath ) . toContain (
366+ expect ( profiler . stats . shardPath ) . toContainPath (
364367 'tmp/profiles/filepath-getter' ,
365368 ) ;
366369 expect ( profiler . stats . shardPath ) . toMatch ( / \. j s o n l $ / ) ;
@@ -372,7 +375,7 @@ describe('NodejsProfiler', () => {
372375 } ) ;
373376 const shardPath = profiler . stats . shardPath ;
374377 // shardPath uses the shard ID format: baseName.shardId.jsonl
375- expect ( shardPath ) . toContain ( 'tmp/profiles/custom-filename' ) ;
378+ expect ( shardPath ) . toContainPath ( 'tmp/profiles/custom-filename' ) ;
376379 expect ( shardPath ) . toMatch ( / t r a c e \. \d { 8 } - \d { 6 } - \d { 3 } (?: \. \d + ) { 3 } \. j s o n l $ / ) ;
377380 // finalFilePath uses measureName as the identifier
378381 expect ( profiler . stats . finalFilePath ) . toBe (
@@ -384,7 +387,7 @@ describe('NodejsProfiler', () => {
384387 const profiler = createProfiler ( 'sharded-path' ) ;
385388 const filePath = profiler . stats . shardPath ;
386389 // When measureName is provided, it's used as the groupId directory
387- expect ( filePath ) . toContain ( 'tmp/profiles/sharded-path' ) ;
390+ expect ( filePath ) . toContainPath ( 'tmp/profiles/sharded-path' ) ;
388391 expect ( filePath ) . toMatch ( / \. j s o n l $ / ) ;
389392 } ) ;
390393
@@ -423,7 +426,8 @@ describe('NodejsProfiler', () => {
423426 / ^ \^ | \$ $ / g,
424427 '' ,
425428 ) ;
426- expect ( stats . shardPath ) . toMatch (
429+ // Normalize path before regex matching to handle OS-specific separators
430+ expect ( osAgnosticPath ( stats . shardPath ) ) . toMatch (
427431 new RegExp (
428432 `^tmp/profiles/stats-getter/trace\\.${ instanceIdPattern } \\.jsonl$` ,
429433 ) ,
0 commit comments