Latest Threat Research:Malicious dYdX Packages Published to npm and PyPI After Maintainer Compromise.Details
Socket
Book a DemoInstallSign in
Socket

espowerify

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

espowerify

Browserify transform for power-assert

Source
npmnpm
Version
0.9.1
Version published
Weekly downloads
538
0.37%
Maintainers
1
Weekly downloads
 
Created
Source

espowerify

Build Status NPM version Dependency Status

Browserify transform for power-assert.

DESCRIPTION

espowerify is a browserify transform for power-assert.

espowerify applies espower to target sources through browserify transform chain. espower manipulates assertion expression (JavaScript Code) represented as Mozilla JavaScript AST, to instrument power-assert feature into the code.

Please note that espowerify is a beta version product. Pull-requests, issue reports and patches are always welcomed.

See power-assert project for more documentation.

CHANGELOG

See CHANGELOG

HOW TO USE

First, install power-assert and espowerify via npm.

$ npm install --save-dev power-assert espowerify

Second, require power-assert in your test.

--- a/test/your_test.js
+++ b/test/your_test.js
@@ -1,4 +1,4 @@
-var assert = require('assert');
+var assert = require('power-assert');

Third, apply espowerify through browserify transform.

by command-line,

$ browserify -t espowerify test/your_test.js > dist/your_test.js

or programmatically,

var source = require('vinyl-source-stream');
var browserify = require('browserify');

gulp.task('build_test', function() {
    var b = browserify({entries: './test/*test.js'});
    b.transform('espowerify');
    return b.bundle()
        .pipe(source('all_test.js'))
        .pipe(gulp.dest('./build'));
});

Lastly, run your test in your way. For example,

$ mocha-phantomjs path/to/test.html

SOURCE MAPS

espowerify supports source maps. espowerify generates source maps with all original sources inlined then adds the resulting source map base64 encoded to the bottom of the transformed code.

This allows debugging the original code when using the debug flag -d with browserify.

$ browserify -d -t espowerify test/your_test.js > dist/your_test_with_sourcemaps.js

or programmatically (see debug: true option),

var source = require('vinyl-source-stream');
var browserify = require('browserify');
var mold = require('mold-source-map');

gulp.task('build_test', function() {
    var b = browserify({entries: './test/*test.js', debug: true});
    b.transform('espowerify');
    return b.bundle()
        .pipe(mold.transformSourcesRelativeTo(__dirname))
        .pipe(source('all_test.js'))
        .pipe(gulp.dest('./build'));
});

(note: mold-source-map module adjusts absolute paths in resulting sourcemaps to relative path. This is required if you are debugging with Firefox)

If the debug flag is not set, these source maps will be removed by browserify and thus will not be contained inside your bundle.

API

espowerify(filepath, options)

Apply espower through the browserify transform chain.

options.patterns

typedefault value
Array of stringobjects shown below
[
    'assert(value, [message])',
    'assert.ok(value, [message])',
    'assert.equal(actual, expected, [message])',
    'assert.notEqual(actual, expected, [message])',
    'assert.strictEqual(actual, expected, [message])',
    'assert.notStrictEqual(actual, expected, [message])',
    'assert.deepEqual(actual, expected, [message])',
    'assert.notDeepEqual(actual, expected, [message])'
]

Target patterns for power assert feature instrumentation. (This option could be passed by programmatical way only)

If callee name (for example, assert.equal) matches exactly and number of arguments is satisfied, then the assertion will be modified. Detection is done by escallmatch. Any arguments enclosed in bracket (for example, [message]) means optional parameters. Without bracket means mandatory parameters.

AUTHOR

  • Takuto Wada

CONTRIBUTORS

LICENSE

Licensed under the MIT license.

Keywords

power-assert

FAQs

Package last updated on 02 Sep 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts