Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chai-checkmark

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chai-checkmark

A Chai plugin for counting assertions.

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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.

Keywords

FAQs

Package last updated on 18 Dec 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc