Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

esplan

teppeis7MIT0.1.2

Count assertions in your test cases with static code analysis

test, assert

readme

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>