{ "source": "doc/api/assert.markdown", "modules": [ { "textRaw": "Assert", "name": "assert", "stability": 5, "stabilityText": "Locked", "desc": "
This module is used for writing unit tests for your applications, you can\naccess it with require('assert')
.\n\n
Throws an exception that displays the values for actual
and expected
separated by the provided operator.\n\n
Tests if value is truthy, it is equivalent to assert.equal(true, !!value, message);
\n\n
Tests shallow, coercive equality with the equal comparison operator ( ==
).\n\n
Tests shallow, coercive non-equality with the not equal comparison operator ( !=
).\n\n
Tests for deep equality.\n\n
\n", "signatures": [ { "params": [ { "name": "actual" }, { "name": "expected" }, { "name": "message", "optional": true } ] } ] }, { "textRaw": "assert.notDeepEqual(actual, expected[, message])", "type": "method", "name": "notDeepEqual", "desc": "Tests for any deep inequality.\n\n
\n", "signatures": [ { "params": [ { "name": "actual" }, { "name": "expected" }, { "name": "message", "optional": true } ] } ] }, { "textRaw": "assert.strictEqual(actual, expected[, message])", "type": "method", "name": "strictEqual", "desc": "Tests strict equality, as determined by the strict equality operator ( ===
)\n\n
Tests strict non-equality, as determined by the strict not equal operator ( !==
)\n\n
Expects block
to throw an error. error
can be constructor, RegExp
or\nvalidation function.\n\n
Validate instanceof using constructor:\n\n
\nassert.throws(\n function() {\n throw new Error("Wrong value");\n },\n Error\n);
\nValidate error message using RegExp:\n\n
\nassert.throws(\n function() {\n throw new Error("Wrong value");\n },\n /value/\n);
\nCustom error validation:\n\n
\nassert.throws(\n function() {\n throw new Error("Wrong value");\n },\n function(err) {\n if ( (err instanceof Error) && /value/.test(err) ) {\n return true;\n }\n },\n "unexpected error"\n);
\n",
"signatures": [
{
"params": [
{
"name": "block"
},
{
"name": "error",
"optional": true
},
{
"name": "message",
"optional": true
}
]
}
]
},
{
"textRaw": "assert.doesNotThrow(block[, message])",
"type": "method",
"name": "doesNotThrow",
"desc": "Expects block
not to throw an error, see assert.throws
for details.\n\n
Tests if value is not a false value, throws if it is a true value. Useful when\ntesting the first argument, error
in callbacks.\n