esplan

0.1.2 • Public • Published

esplan NPM version build status Dependency Status

Description

Count assertions in your test cases with static code analysis before execution and wait until all assertions are completed.

Example

Input:

var esplan = require('esplan');
var assert = esplan.register(require('assert'));
 
describe('Promise', function() {
    it('can not detect an assertion error in `then` function', function() {
        mayBeResolve().then(function(value) {
            assert.equal(value.length, 2);
            assert.equal(value[0], 'foo');
            assert.equal(value[1], 'bar');
        });
    });
});

Output:

var esplan = require('esplan');
var assert = esplan.register(require('assert'));
 
describe('Promise', function () {
    // `$$done` is added!
    it('can not detect an assertion error in `then` function', function($$done) {
        assert.$$plan(this, 3, $$done); // this line is inserted!
        mayBeResolve().then(function (value) {
            assert.equal(value.length, 2);
            assert.equal(value[0], 'foo');
            assert.equal(value[1], 'bar');
        });
    });
});

Result (If mayBeResolve() returns wrong value ['foo', 'wrong!']):

Error: Expected 3 assertions, but actually 2 assertions called

License

MIT License: Teppei Sato <teppeis@gmail.com>

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.2
    2
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.1.2
    2
  • 0.1.1
    0
  • 0.1.0
    0

Package Sidebar

Install

npm i esplan

Weekly Downloads

2

Version

0.1.2

License

MIT

Last publish

Collaborators

  • teppeis