useOracleClock: return advance(ms), and fake performance (or document what it fakes)

Open
#67 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
32/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
javascript
Domain
testing

Research direction

Start in src/oracle-property.ts near the toFake list (around line 1070), which covers setTimeout, setInterval, and Date but not performance. Then read the framework self-oracle's controlled-clock law, since the issue requires an oracle-first change (P9) before the code change. Done means useOracleClock returns advance(ms), performance is either faked or its fakes are listed in the JSDoc, and the self-oracle passes.

Written by the indexing model from the issue text.

Description

Reported from an adopter's first session, at c58b0c2. Not yet reproduced here.

(a) Add an advance(ms) helper. useOracleClock should return advance(ms). Then drivers never import their own vi, which also avoids the problem in the two-Vitest-copies issue.

(b) Fake performance. Today toFake covers setTimeout, clearTimeout, setInterval, clearInterval and Date (src/oracle-property.ts around line 1070). In the adopter's client, a deadline timer re-checks performance.now(), so a virtual timeout kept re-arming until real time caught up. Their workaround: vi.spyOn(performance, 'now').mockImplementation(() => Date.now()). Add performance to toFake, or at least list in the JSDoc exactly what it fakes.

This is a framework change, so it needs an oracle-first change (P9) to the framework self-oracle's controlled-clock law.

This issue was written by Isaac.

Dominant language
JavaScript
Stars
5
Forks
1
Avg merge
6h
Merged PRs (30d)
56

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from TanStack/oracles

All issues in TanStack/oracles

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.