Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

empower

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

empower

Power Assert feature enhancer for assert function/object

  • 0.9.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
150K
increased by23.62%
Maintainers
1
Weekly downloads
 
Created
Source

empower

Build Status NPM version Dependency Status Coverage Status Code Climate License Built with Gulp

Power Assert feature enhancer for assert function/object.

DESCRIPTION

empower is a core module of power-assert family. empower enhances standard assert function or any assert-like object to work with power-assert feature added code instrumented by espower.

empower works with standard assert function (best fit with Mocha), and also supports assert-like objects/functions provided by various testing frameworks such as QUnit, buster.js, and nodeunit.

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

CHANGELOG

See CHANGELOG

API

var enhancedAssert = empower(originalAssert, formatter, [options])

return type
function or object

empower function takes function or object(originalAssert) and formatter function created by power-assert-formatter then returns PowerAssert feature added function/object base on originalAssert. If destructive option is falsy, originalAssert will be unchanged. If destructive option is truthy, originalAssert will be manipulated directly and returned enhancedAssert will be the same instance of originalAssert.

originalAssert
typedefault value
function or objectN/A

originalAssert is an instance of standard assert function or any assert-like object. see SUPPORTED ASSERTION LIBRARIES and ASSERTION LIBRARIES KNOWN TO WORK section. Be careful that originalAssert will be manipulated directly if destructive option is truthy.

formatter
typedefault value
functionN/A

formatter function created by power-assert-formatter.

options
typedefault value
object(return value of empower.defaultOptions())

Configuration options. If not passed, default options will be used.

options.destructive
typedefault value
booleanfalse

If truthy, modify originalAssert destructively.

If false, empower mimics originalAssert as new object/function, so originalAssert will not be changed. If true, originalAssert will be manipulated directly and returned enhancedAssert will be the same instance of originalAssert.

options.modifyMessageOnRethrow
typedefault value
booleanfalse

If truthy, modify message property of AssertionError on rethrow.

options.saveContextOnRethrow
typedefault value
booleanfalse

If truthy, add powerAssertContext property to AssertionError on rethrow.

modifyMessageOnRethrow option and saveContextOnRethrow option makes behavior matrix as below.

modifyMessageOnRethrowsaveContextOnRethrowresulting behavior
false (default)false (default)Always modify assertion message argument directly
truefalseModify message of AssertionError on fail
falsetrueDo not modify message of AssertionError but add powerAssertContext property on fail
truetrueOn fail, modify message of AssertionError and also add powerAssertContext property
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.

Pattern detection is done by escallmatch. Any arguments enclosed in bracket (for example, [message]) means optional parameters. Without bracket means mandatory parameters.

var options = empower.defaultOptions();

Returns default options object for empower function. In other words, returns

{
    destructive: false,
    modifyMessageOnRethrow: false,
    saveContextOnRethrow: false,
    patterns: [
        '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])'
    ]
}

SUPPORTED ASSERTION LIBRARIES

ASSERTION LIBRARIES KNOWN TO WORK

INSTALL

via npm

Install

$ npm install --save-dev empower

via bower

Install

$ bower install --save-dev empower

Then load (empower function is exported)

<script type="text/javascript" src="./path/to/bower_components/empower/build/empower.js"></script>

AUTHOR

LICENSE

Licensed under the MIT license.

Keywords

FAQs

Package last updated on 07 Oct 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc