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

chai-checkmark

v1.0.1

Published

A Chai plugin for counting assertions.

Downloads

8,743

Readme

Chai Checkmark

Checkmark is a Chai plugin for counting assertions made during a test. Often, when dealing with asynchronous tests, it can be difficult to determine if a callback was actually called. With Checkmark, you can be assured that the assertion was made.

Installation

Include Checkmark in the browser, as a CommonJS module, or through AMD.

<!-- Browser -->
<script src="chai.js"></script>
<script src="chai-checkmark.js"></script>
// CommonJS
var chai = require("chai"),
    plugin = require("chai-checkmark")
chai.use(plugin)
// AMD
require(["chai", "chai-checkmark"], function(chai, plugin) {
    chai.use(plugin)
})

How to use

describe("something", function() {
  it("should check two things", function(next) {
    expect(2).checks(next) // <-- pass in the callback

    "sync test".should.be.a("string").mark() // <-- check 1

    setTimeout(function() {
      // check 2, callback is called after the current event finishes
      "async test".should.be.a("string").mark()
    }, 500)
  })
})

API

Checkmark builds on Chai's assertion library by adding just two methods:

expect(Number).check(Function) or .checks(Function)

This must be called before .mark() but doesn't have to be at the very beginning of a test. You establish how many times you expect .mark() to be called and optionally pass in a callback to be called when the number of marks is reached.

expect(str).to.be.a("string").mark()

Add .mark() to the end of every assertion to which you want to have tracked by Checkmark. You can use any number of Chai's assertions, including .and, as long as you end your statement with .mark().

Contributing

Pull Requests are welcome. They will only be merged if they are based off the tip of the develop branch. Please rebase (don't merge!) your changes if you are behind. To learn about why rebase is better than merge, check out The Case for Git Rebase.

In short, to bring your Working Copy up to the tip of develop, you can use the rebase feature: git pull --rebase. See Pull with Rebase for details.