Skip to content
This repository has been archived by the owner on May 18, 2019. It is now read-only.
/ esplan Public archive

Count assertions in your test cases with static code analysis

Notifications You must be signed in to change notification settings

teppeis/esplan

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

esplan

NPM version build status Dependency Status MIT License

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 <[email protected]>

About

Count assertions in your test cases with static code analysis

Resources

Stars

Watchers

Forks

Packages

No packages published