code

assertion library

This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
Last updated 7 years ago by hueniverse .
BSD-3-Clause · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install code 
SYNC missed versions from official npm registry.

code

BDD assertion library.

Current Version Build Status

Lead Maintainer - Colin Ihrig

Example

const Code = require('code');
const expect = Code.expect;

expect(true).to.be.a.boolean().and.to.not.equal(false);
expect('this string').to.only.include(['this', 'string']);

Acknowledgments

code was created as a direct rewrite of the powerful chai assertions library. This virtual fork was created for a few reasons. First, chai mixed usage of methods and properties creates a problematic environment in which it is too easy to forget a method () and result in an assertion that is never executed (and therefor passes incorrectly). This observation was noted by the must author.

The second reason is that similar to lab, our test runner, we wanted an assertion library that is small, simple, and intuitive - without plugins, extensions, or the overhead of having to support testing in the browser. code provides much of the same functionality in about 300 lines of code that are trivial to read in a few minutes.

And last, we wanted to experiment with some new features that allow deeper integration between the test runner and assertions library. The first of which are two methods exported (and used by lab) for getting the total assertions count (which is a measure of the tests comprehensiveness), and by verifying that every assertion created (e.g. every expect() call) is also executed. This will alert when a statement like expect(5).to.be.a.string is not allowed to remain unnoticed (and fail to throw due to the missing ()).

Like lab, the goal is to keep this module small and simple. If you need extensibility or other functionality, we recommend looking at the many other excellent assertions libraries available.

API

See the API Reference.

Current Tags

  • 5.2.4                                ...           latest (7 years ago)

30 Versions

  • 5.2.4 [deprecated]           ...           7 years ago
  • 5.2.3 [deprecated]           ...           7 years ago
  • 5.2.2 [deprecated]           ...           7 years ago
  • 5.2.1 [deprecated]           ...           7 years ago
  • 5.2.0 [deprecated]           ...           8 years ago
  • 5.1.2 [deprecated]           ...           8 years ago
  • 5.1.0 [deprecated]           ...           9 years ago
  • 5.0.0 [deprecated]           ...           9 years ago
  • 4.1.0 [deprecated]           ...           9 years ago
  • 4.0.0 [deprecated]           ...           10 years ago
  • 3.0.2 [deprecated]           ...           10 years ago
  • 3.0.1 [deprecated]           ...           10 years ago
  • 3.0.0 [deprecated]           ...           10 years ago
  • 2.3.0 [deprecated]           ...           10 years ago
  • 2.2.1 [deprecated]           ...           10 years ago
  • 2.2.0 [deprecated]           ...           10 years ago
  • 2.1.1 [deprecated]           ...           10 years ago
  • 2.1.0 [deprecated]           ...           10 years ago
  • 2.0.1 [deprecated]           ...           10 years ago
  • 2.0.0 [deprecated]           ...           10 years ago
  • 1.5.0 [deprecated]           ...           11 years ago
  • 1.4.1 [deprecated]           ...           11 years ago
  • 1.4.0 [deprecated]           ...           11 years ago
  • 1.3.0 [deprecated]           ...           11 years ago
  • 1.2.1 [deprecated]           ...           11 years ago
  • 1.2.0 [deprecated]           ...           11 years ago
  • 1.1.1 [deprecated]           ...           11 years ago
  • 1.1.0 [deprecated]           ...           11 years ago
  • 1.0.0 [deprecated]           ...           11 years ago
  • 0.0.0 [deprecated]           ...           11 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 22
Last Day 0
Last Week 22
Last Month 2
Dependencies (1)
Dev Dependencies (2)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |