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

Abierto Apto para principiantes
#210 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
69/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
node.js, typescript
Área
devtools, testing

Línea de trabajo

Empieza por rastrear mock.clock(on).set(ms) en el plugin de Vitest y compara su comportamiento con la validación del reloj del motor descrita en el issue. La reproducción usa vitest.config.ts y una prueba que avanza el reloj hasta 1000 ms y luego lo establece en 500 ms. El trabajo estará terminado cuando ese caso también lance el error del motor por retroceso del reloj en el plugin de Vitest.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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).
Lenguaje dominante
TypeScript
Estrellas
0
Forks
0
Merge medio
29 min
PR fusionados (30 d)
138

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de kwitsch/claude-code-plugin-tooling

Todos los issues de kwitsch/claude-code-plugin-tooling

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.