> Sinon.js Test Doubles
Spies, stubs, mocks, and fake timers with Sinon.js for JavaScript testing.
fetch
$
curl "https://skillshub.wtf/skillshub-team/catalog-batch5/sinon-mocking?format=md"SKILL.md•Sinon.js Test Doubles
Sinon.js
Spies
const spy = sinon.spy(obj, 'method');
obj.method('arg');
expect(spy.calledWith('arg')).to.be.true;
spy.restore();
Stubs
const stub = sinon.stub(api, 'fetch');
stub.resolves({ id: 1, name: 'Alice' });
stub.withArgs('error').rejects(new Error('fail'));
Fake Timers
const clock = sinon.useFakeTimers();
const debounced = debounce(fn, 100);
debounced(); debounced();
clock.tick(100);
expect(fn.callCount).to.equal(1);
clock.restore();
Sandbox (auto-cleanup)
const sandbox = sinon.createSandbox();
afterEach(() => sandbox.restore());
sandbox.stub(api, 'fetch').resolves([]);
> related_skills --same-repo
> Nix Dev Shells with direnv
Auto-activate reproducible dev environments with Nix flakes and direnv.
> Dagger with GitHub Actions
Run Dagger CI/CD pipelines in GitHub Actions for portable, testable builds.
> Bun + Hono API
Build fast APIs with Bun runtime and Hono framework.
> Deno Fresh Framework
Build full-stack web apps with Fresh on Deno. Islands, routes, and zero runtime overhead.
┌ stats
installs/wk0
░░░░░░░░░░first seenMar 18, 2026
└────────────