jarle/bun-skills/bun-guides-test-mock-clock

Claude Code and agent skill by jarle/bun-skills

Trust tier 3
  • community
  • ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Source check pending

Checking that the SKILL.md file is still in the repository.

Set the system time in Bun's test runner

Install

npx vskill@latest install jarle/bun-skills/bun-guides-test-mock-clock

Semi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard

SKILL.md

The same SKILL.md was published earlier as jarle/bun-skills/bun-guides-test-mock-clock.

Set the system time in Bun's test runner

Bun's test runner supports setting the system time programmatically with the setSystemTime function.

ts theme={"theme":{"light":"github-light","dark":"dracula"}}
import { test, expect, setSystemTime } from "bun:test";
test("party like it's 1999", () => {
const date = new Date("1999-01-01T00:00:00.000Z");
setSystemTime(date); // it's now January 1, 1999
const now = new Date();
expect(now.getFullYear()).toBe(1999);
expect(now.getMonth()).toBe(0);
expect(now.getDate()).toBe(1);
});

The setSystemTime function is commonly used on conjunction with Lifecycle Hooks to configure a testing environment with a deterministic "fake clock".

ts theme={"theme":{"light":"github-light","dark":"dracula"}}
import { test, expect, beforeAll, setSystemTime } from "bun:test";
beforeAll(() => {
const date = new Date("1999-01-01T00:00:00.000Z");
setSystemTime(date); // it's now January 1, 1999
});
// tests...

To reset the system clock to the actual time, call setSystemTime with no arguments.

ts theme={"theme":{"light":"github-light","dark":"dracula"}}
import { test, expect, beforeAll, setSystemTime } from "bun:test";
setSystemTime(); // reset to actual time

See Docs > Test Runner > Date and time for complete documentation on mocking with the Bun test runner.

Security

  • Security scanPassed, 90 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
5

Not refreshed yet.

Extension points

  • hookPre/post lifecycle hooks

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/jarle/bun-skills/bun-guides-test-mock-clock/badge)](https://verified-skill.com/skills/jarle/bun-skills/bun-guides-test-mock-clock)

Something wrong with this skill or its page? Tell us.