espower-loader

Power Assert feature instrumentor on the fly

npm install espower-loader
25 downloads in the last day
90 downloads in the last week
274 downloads in the last month

espower-loader

Build Status NPM version Dependency Status Built with Grunt

Power Assert feature instrumentor on the fly.

DESCRIPTION

espower-loader is a Node.js module loader that enhances target sources on the fly. So you can instrument Power Assert feature without code generation for now.

espower-loader applies espower to target sources on loading them. espower manipulates assertion expression (JavaScript Code) represented as Mozilla JavaScript AST, to instrument power-assert feature into the code.

Please note that espower-loader is a beta version product. Pull-requests, issue reports and patches are always welcomed. See power-assert project for more documentation.

FYI: You may be interested in intelli-espower-loader to go one step further. With intelli-espower-loader, you don't need to create loader file (like enable-power-assert.js). Just define test directory in package.json wow!

EXAMPLE

You can instrument power-assert without code generation (e.g. without using grunt-espower).

For mocha, Just add --require option.

$ mocha --require ./path/to/enable-power-assert test/some_test_using_powerassert.js

where enable-power-assert.js somewhere in your project is,

require('espower-loader')({
    cwd: process.cwd(),
    pattern: 'test/**/*.js'
});

You can specify espower options explicitly.

require('espower-loader')({

    // directory where match starts with
    cwd: process.cwd(),

    // glob pattern using minimatch module
    pattern: 'test/**/*.js',

    // options for espower module
    espowerOptions: {
        destructive: false,
        powerAssertVariableName: 'assert',
        lineSeparator: '\n',
        targetMethods: {
            oneArg: [
                'ok'
            ],
            twoArgs: [
                'equal',
                'notEqual',
                'strictEqual',
                'notStrictEqual',
                'deepEqual',
                'notDeepEqual'
            ]
        }
    }
});

AUTHOR

LICENSE

Licensed under the MIT license.

npm loves you