Power Assert feature enhancer for assert function/object.
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.
Pull-requests, issue reports and patches are always welcomed. See power-assert project for more documentation.
See CHANGELOG
var enhancedAssert = empower(originalAssert, formatter, [options]) return typefunction
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
.
function
or object
N/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.
function
N/A
formatter function created by power-assert-formatter.
type default valueobject
(return value of empower.defaultOptions()
)
Configuration options. If not passed, default options will be used.
type default valueboolean
false
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
.
boolean
false
If truthy, modify message
property of AssertionError on rethrow.
boolean
false
If truthy, add powerAssertContext
property to AssertionError on rethrow.
modifyMessageOnRethrow
option and saveContextOnRethrow
option makes behavior matrix as below.
false
(default) false
(default) Always modify assertion message argument directly true
false
Modify message
of AssertionError on fail false
true
Do not modify message
of AssertionError but add powerAssertContext
property on fail true
true
On fail, modify message
of AssertionError and also add powerAssertContext
property type default value Array
of string
objects 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])', 'assert.deepStrictEqual(actual, expected, [message])', 'assert.notDeepStrictEqual(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.
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])', 'assert.deepStrictEqual(actual, expected, [message])', 'assert.notDeepStrictEqual(actual, expected, [message])' ] }SUPPORTED ASSERTION LIBRARIES ASSERTION LIBRARIES KNOWN TO WORK
Install
$ npm install --save-dev empower
use empower npm module on browser
empower
function is exported
<script type="text/javascript" src="./path/to/node_modules/empower/build/empower.js"></script>
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>
We support Node under maintenance. In other words, we stop supporting old Node version when their maintenance ends.
We also support "modern enough" browsers such as Chrome, Firefox, Safari, Edge etc.
Any other environments are not supported officially (means that we do not test against them on CI service). empower is known to work with old browsers, and trying to keep them working though.
Licensed under the MIT license.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4