vitest plugin: clock.set(ms) goes backwards, the engine's clock does not

Offen Anfängerfreundlich
#210 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
69/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
node.js, typescript
Bereich
devtools, testing

Rechercherichtung

Verfolge zunächst mock.clock(on).set(ms) im Vitest-Plugin und vergleiche sein Verhalten mit der im Issue beschriebenen Validierung der Uhr durch die Engine. Für die Reproduktion werden vitest.config.ts und ein Test verwendet, der die Uhr auf 1000 ms vorstellt und sie dann auf 500 ms setzt. Fertig ist die Arbeit, wenn dieser Fall auch unter dem Vitest-Plugin den Fehler der Engine für eine rückwärts laufende Uhr auslöst.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

bug

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-mod 0.18.0
  • claude --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) and mock.env read live (#207).
Vorherrschende Sprache
TypeScript
Sterne
0
Forks
0
Ø Merge
29 Min.
Gemergte PRs (30 T.)
138

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus kwitsch/claude-code-plugin-tooling

Alle Issues in kwitsch/claude-code-plugin-tooling

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.