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 🙏

© 2024 – Pkg Stats / Ryan Hefner

assertly-sinon

v1.0.1

Published

Assertly add-on for sinon

Downloads

17

Readme

assertly-sinon

An assertly (npm) add-on package for sinon (npm).

Build Status Dependencies Status npm version MIT Licence

If you are using sinon, this module expands Assertly with new words specific to testing spy and spyCall objects created by sinon. For example:

expect(spy).to.always.return(42);

Installation

To install using npm:

$ npm install assertly-sinon --save-dev

To install using yarn:

$ yarn add assertly-sinon --dev

Usage

To use this add-on, pass its init() method to Assert.register() like so:

const Assert = require('assertly');
const AssertlySinon = require('assertly-sinon');

Assert.register(AssertlySinon.init);

Improved Output (Optional)

By default, spys and spyCalls do not print cleanly using Node.js inspect() method. To improve this, you can use prettySpy:

let spy = AssertlySinon.prettySpy(sinon.spy(object, method));

The prettySpy method ensures that the spy and any spyCalls it returns from getCall have a suitable inspect() method.

API

The sinon API provides many kinds of helpers for spying and mocking. The API's provided by this add-on are designed to make BDD-style assertions for sinon's spys and spyCalls. To make it clear which sinon types work in specific contexts, the names used for parameters are chosen to convey this as shown below:

  • spy - A spy created by sinon.spy()
  • spyCall - A call to a spy returned by sinon.spy().getCall()
  • spyOrCall - Either a spy or a spyCall

See these documents for the mapping of the sinon Spy API and Spy Call API.

Assertions

Properties

Modifiers

This add-on adds new modifiers to Assertly.

always

The always modifier is used by return and throw assertions when operating on a spy.