Skip to content

Commit 1321cbe

Browse files
committed
refactor: wip
1 parent d8978e1 commit 1321cbe

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

packages/utils/src/lib/profiler/profiler-node.unit.test.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { performance } from 'node:perf_hooks';
22
import { 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';
47
import {
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(/\.jsonl$/);
@@ -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(/trace\.\d{8}-\d{6}-\d{3}(?:\.\d+){3}\.jsonl$/);
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(/\.jsonl$/);
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

Comments
 (0)