goalline How it worksClaude Code hookGitHub ActionBenchmarkCommandsGitHub

goalline / The clock

Find the tests that read the real clock

A test that reads the real clock can pass today and fail tomorrow on the same code. During goalline run, goalline counts every Date.now(), new Date() and Date() your own tests and source files make, and a pass that read the clock counts only until the next midnight.

Why a pass can expire

The same code can pass today and fail tomorrow when a test reads the real clock: a token that expires after 30 days, a report for 'this month', a fixture date that is now in the past. A cache keyed by the code alone can't see that, and the clock can't be hashed, because it changes every second. So goalline watches who reads it.

See it

goalline run --gate unit -- npx vitest run
goalline: unit PASSED · 4/4 passed · 2s · tree 47f3402 = commit fea9c46 · reads the real clock (2 read(s), e.g. src/today.mjs:1): counts until 10-25 00:00

goalline verify shows how long the pass counts. After midnight, verify and --reuse say why it no longer does: it read the real clock (src/today.mjs:1), so its pass expired at 10-25 00:00.

Whose read it is

Where it works

Jest, including the vm contexts its node and jsdom environments run in; Vitest, in its forks, threads and vmThreads pools; and node --test. Checked against Jest 29.7 and 30.5 and Vitest 5.0. The watch adds about 5 to 10 microseconds for each clock read it looks at, and Jest itself makes about 80 per test file.

Options

Limits

Related