vitest plugin: clock.set(ms) goes backwards, the engine's clock does not
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 69/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- node.js, typescript
Research direction
Start by tracing mock.clock(on).set(ms) in the Vitest plugin and compare its behavior with the engine’s clock validation described in the issue. The reproduction uses vitest.config.ts and a test that advances to 1000 ms, then sets the clock to 500 ms. Done means that case throws the engine’s backwards-clock error under the Vitest plugin too.
Written by the indexing model from the issue text.
Description
Problem
mock.clock(on).set(ms) moves the kit's clock backwards under the vitest plugin. Under claude plugin test it throws, because the engine's clock does not run backwards. A test that sets the clock to an earlier time (to check a mod that must survive a wall clock stepping back) passes under vitest and fails under the engine.
Versions
@kwitsch/vitest-plugin-claude-code-mod0.18.0claude --version: 2.1.336 (Claude Code)- vitest 5.1.2
- node v26.14.0
Minimal reproduction
Any plugin (the test uses no mod hook): package.json {"name":"scratch","version":"0.0.1","type":"module"}, plugin/.claude-plugin/plugin.json with the same name, plugin/hooks/hooks.json {"modules":["./register.js"]}, plugin/hooks/register.js export const register = (on) => { on("session.start", async ($, e, next) => next(e)); }; (also as src/register.js), vitest.config.ts with claudeCodeMod({ mod: "./src/register.js", portable: "error" }).
import { expect, mock, test } from "claude-code/testing";
test("T4 the clock can be set back", async ($, on) => {
const clock = mock.clock(on);
await clock.advance(1000);
await clock.set(500);
expect(clock.now()).toBe(500);
});
vitest: passes. claude plugin test:
(fail) T4 the clock can be set back [0.62ms]
TypeError: set(ms): a time in milliseconds at or past now (1000); the clock does not run backwards
Expected
clock.set(ms) with ms before the clock's now throws the engine's error (set(ms): a time in milliseconds at or past now (<now>); the clock does not run backwards) under the vitest plugin too.
Relations
- Part of #41, found while migrating jevfort (kwitsch/claude-plugins-development#196): its test "A clock that reads earlier than the last timeout ends the pause (a new session)" needs a clock reading earlier, which neither runner offers through
set. - Same family as #205, #206, #207 and #33 (the kit accepts what the engine rejects). jevfort also hit the other three: a second stub for one event (
on("session.start") registered twice, #205), an option of the wrong type (#206) andmock.envread live (#207).
- Dominant language
- TypeScript
- Stars
- 0
- Forks
- 0
- Avg merge
- 29m
- Merged PRs (30d)
- 138
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from kwitsch/claude-code-plugin-tooling
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
kwitsch/claude-code-plugin-tooling#219 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 54/100
kwitsch/claude-code-plugin-tooling#212 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 48/100
kwitsch/claude-code-plugin-tooling#209 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 45/100
kwitsch/claude-code-plugin-tooling#208 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 52/100
kwitsch/claude-code-plugin-tooling#207 ·
Maintainers usually reply within 1 day
All issues in kwitsch/claude-code-plugin-tooling
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Maintainers usually reply within 1 day
-
Codex使用可 かんたん コード
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ryuki-moro/Nicomaru#348 ·
Maintainers usually reply within 1 day
-
clawsweeper:fix-shape-clear clawsweeper:needs-maintainer-review clawsweeper:needs-product-decision clawsweeper:no-new-fix-pr clawsweeper:source-repro impact:crash-loop issue-rating: 🦞 diamond lobster P2
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
openclaw/openclaw#211919 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 1 day
-
Bug
Difficulty 1/5 Under an hour Newbie friendliness 84/100
Maintainers usually reply within 1 day