Giter Club home page Giter Club logo

code's Introduction

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.

code's People

Contributors

adrieankhisbe avatar arb avatar blacksun1 avatar cjihrig avatar geek avatar hueniverse avatar iamdoron avatar joaojeronimo avatar jseppi avatar krisb avatar manonthemat avatar marsup avatar sibartlett avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.