Sha256: ec270d8929498670b8858bf64f1148ddfe0b8fafd6326f208521a85a385c3e31

Contents?: true

Size: 1.18 KB

Versions: 5

Compression:

Stored size: 1.18 KB

Contents

/*!
 * Simple util module to track tests. Adds a process.exit hook to print
 * the undone tests.
 */


exports.createTracker = function (on_exit) {
    var names = {};
    var tracker = {
        names: function () {
            var arr = [];
            for (var k in names) {
                if (names.hasOwnProperty(k)) {
                    arr.push(k);
                }
            }
            return arr;
        },
        unfinished: function () {
            return tracker.names().length;
        },
        put: function (testname) {
            names[testname] = testname;
        },
        remove: function (testname) {
            delete names[testname];
        }
    };

    process.on('exit', function() {
        on_exit = on_exit || exports.default_on_exit;
        on_exit(tracker);
    });

    return tracker;
};

exports.default_on_exit = function (tracker) {
    if (tracker.unfinished()) {
        console.log('');
        console.log('Undone tests (or their setups/teardowns): ');
        var names = tracker.names();
        for (var i = 0; i < names.length; i += 1) {
            console.log(names[i]);
        }
        process.reallyExit(tracker.unfinished());
    }
};

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
trans-0.5.10 template/node_modules/grunt-contrib-nodeunit/node_modules/nodeunit/lib/track.js
trans-0.5.9 template/node_modules/grunt-contrib-nodeunit/node_modules/nodeunit/lib/track.js
mobile_template-0.0.3 templates/cordova_android/bin/node_modules/nodeunit/lib/track.js
mobile_template-0.0.2 templates/cordova_android/bin/node_modules/nodeunit/lib/track.js
mobile_template-0.0.1 templates/cordova_android/bin/node_modules/nodeunit/lib/track.js