npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@rimbu/spy

v0.7.5

Published

Test utilities for spying, stubbing and mocking functions, objects and classes in TypeScript

Readme

npm version

Licence

@rimbu/spy

Welcome to @rimbu/spy! This package provides utilities for creating spies and mocks for functions, objects, and classes, aimed at enhancing your testing experience. Note that it is currently in the experimental phase.

Motivation

Testing frameworks like Deno and ES Modules present challenges for module mocking, unlike Jest. Deno recommends exposing dependencies in a way that allows replacement without module mocking.

While alternatives like Vitest support ES Modules and may be a viable option for those who prefer module mocking, @rimbu/spy focuses on testing without module mocking. This means you cannot replace functions inside other files/modules directly. Instead, dependencies should be encapsulated in an object passed into the dependent code, which can then be spied/mocked.

Key Benefits

  • Framework Independence: Using an external spying/mocking framework reduces dependency on a specific testing framework, easing the transition if you decide to switch.
  • Minimal and Simple API: @rimbu/spy offers a straightforward API that is easy to learn and use, ensuring type consistency with original implementations.
  • Alternative to Sinon JS: While Sinon JS provides extensive functionality, @rimbu/spy offers a simpler, more minimalistic approach.

Why Use @rimbu/spy?

  • No Module Mocking: Ideal for scenarios where module mocking is not feasible or desired.
  • Consistent Types: Ensures that types remain consistent with their original implementations.
  • Ease of Use: Designed to be easy to learn and integrate into your testing workflow.

Feedback and Contributions

We encourage you to try out @rimbu/spy and provide feedback. If you encounter any issues or have suggestions for improvement, please don't hesitate to create issues on our repository.

Docs

Full documentation is still to be done. To read more about Rimbu, please visit the Rimbu Docs, or directly see the Rimbu Spy API Docs.

Or Try Out Rimbu in CodeSandBox.

Installation

Compabitity

Yarn / npm / Bun / Deno

For yarn:

yarn add @rimbu/spy

For npm:

npm i @rimbu/spy

For bun:

bun add @rimbu/spy

For deno:

deno add npm:@rimbu/spy

Usage

import { Spy } from '@rimbu/spy';

const spyConsole = Spy.obj(console, {
  log: () => console.log('mocked'),
});
spyConsole.warn("warning");
// => behaves as normal, logs "warning"
spyConsole.log("hello", "world);
// => logs "mocked"
spyConsole[Spy.META].nrCalls; // => 2
spyConsole.log.nrCalls;       // => 1
spyConsole.warn.calls[0];     // => ["warning"]
spyConsole[Spy.META].callSequence;
// => [["warn", "warning"], ["log", "hello", "world"]]

Author

Created and maintained by Arvid Nicolaas.

Contributing

We welcome contributions! Please read our Contributing guide.

Contributors

Made with contributors-img.

License

This project is licensed under the MIT License. See the LICENSE for details.