Socket
Socket
Sign inDemoInstall

cases

Package Overview
Dependencies
1
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    cases

cases provides parameterized unit tests for Mocha.


Version published
Weekly downloads
4
decreased by-77.78%
Maintainers
1
Install size
78.6 kB
Created
Weekly downloads
 

Readme

Source

cases

cases provides parameterized unit tests for Mocha.

If you have any questions or feedback, feel free to contact me using @goloroden on Twitter.

Installation

$ npm install cases

Quick Start

Using cases is easy. All you need to do is to add a reference to it within your Node.js application:

var cases = require('cases');

Now you can write your tests using Mocha as usual, but you may introduce cases for tests where you need multiple test cases.

test('add returns the sum.', cases([
  [ 23, 42, 65 ],
  [ 12, 17, 29 ]
], function (first, second, expected) {
  var actual = add(first, second);
  assert.that(actual, is.equalTo(expected));
}));

This also works with asynchronous tests. The only difference is that you additionally need to provide the done parameter to your test function.

test('addAsync returns the sum.', cases([
  [ 23, 42, 65 ],
  [ 12, 17, 29 ]
], function (first, second, expected, done) {
  addAsync(first, second, function (actual) {
    assert.that(actual, is.equalTo(expected));
    done();
  });
}));

Running the tests

cases has been developed using TDD. To run the tests, go to the folder where you have installed cases to and run npm test. You need to have mocha installed.

$ npm test

Additionally, this module can be built using Grunt. Besides running the tests, Grunt also analyses the code using JSHint. To run Grunt, go to the folder where you have installed cases and run grunt. You need to have grunt-cli installed.

$ grunt

License

The MIT License (MIT) Copyright (c) 2013 Golo Roden.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

FAQs

Last updated on 10 Apr 2013

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc