Skip to content

Commit 7bc0870

Browse files
committed
fix(test): use hrtime for unique test directories
Replace Date.now() with process.hrtime.bigint() for higher precision timestamps. Tests were failing because Date.now() has millisecond precision, causing tests running in quick succession to share the same directory name.
1 parent 66eb281 commit 7bc0870

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

test/process-lock.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ describe('process-lock', () => {
1919

2020
beforeEach(async () => {
2121
// Create unique test directory for each test.
22+
// Use process.hrtime.bigint() for higher precision than Date.now()
2223
testDir = path.join(
2324
tmpdir(),
24-
`process-lock-test-${Date.now()}-${Math.random().toString(36).slice(2)}`,
25+
`process-lock-test-${process.hrtime.bigint()}-${Math.random().toString(36).slice(2)}`,
2526
)
2627
lockPath = path.join(testDir, 'test.lock')
2728

0 commit comments

Comments
 (0)