{
  "source": "doc/api/assert.md",
  "modules": [
    {
      "textRaw": "Assert",
      "name": "assert",
      "introduced_in": "v0.10.0",
      "stability": 2,
      "stabilityText": "Stable",
      "desc": "<p>The <code>assert</code> module provides a simple set of assertion tests that can be used to\ntest invariants.</p>\n",
      "methods": [
        {
          "textRaw": "assert(value[, message])",
          "type": "method",
          "name": "assert",
          "meta": {
            "added": [
              "v0.5.9"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`value` {any} ",
                  "name": "value",
                  "type": "any"
                },
                {
                  "textRaw": "`message` {any} ",
                  "name": "message",
                  "type": "any",
                  "optional": true
                }
              ]
            },
            {
              "params": [
                {
                  "name": "value"
                },
                {
                  "name": "message",
                  "optional": true
                }
              ]
            }
          ],
          "desc": "<p>An alias of <a href=\"#assert_assert_ok_value_message\"><code>assert.ok()</code></a>.</p>\n"
        },
        {
          "textRaw": "assert.deepEqual(actual, expected[, message])",
          "type": "method",
          "name": "deepEqual",
          "meta": {
            "added": [
              "v0.1.21"
            ],
            "changes": [
              {
                "version": "v8.0.0",
                "pr-url": "https://github.com/nodejs/node/pull/12142",
                "description": "Set and Map content is also compared"
              },
              {
                "version": "v6.4.0, v4.7.1",
                "pr-url": "https://github.com/nodejs/node/pull/8002",
                "description": "Typed array slices are handled correctly now."
              },
              {
                "version": "v6.1.0, v4.5.0",
                "pr-url": "https://github.com/nodejs/node/pull/6432",
                "description": "Objects with circular references can be used as inputs now."
              },
              {
                "version": "v5.10.1, v4.4.3",
                "pr-url": "https://github.com/nodejs/node/pull/5910",
                "description": "Handle non-`Uint8Array` typed arrays correctly."
              }
            ]
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`actual` {any} ",
                  "name": "actual",
                  "type": "any"
                },
                {
                  "textRaw": "`expected` {any} ",
                  "name": "expected",
                  "type": "any"
                },
                {
                  "textRaw": "`message` {any} ",
                  "name": "message",
                  "type": "any",
                  "optional": true
                }
              ]
            },
            {
              "params": [
                {
                  "name": "actual"
                },
                {
                  "name": "expected"
                },
                {
                  "name": "message",
                  "optional": true
                }
              ]
            }
          ],
          "desc": "<p>Tests for deep equality between the <code>actual</code> and <code>expected</code> parameters.\nPrimitive values are compared with the <a href=\"https://tc39.github.io/ecma262/#sec-abstract-equality-comparison\">Abstract Equality Comparison</a>\n( <code>==</code> ).</p>\n<p>Only <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Enumerability_and_ownership_of_properties\">enumerable &quot;own&quot; properties</a> are considered. The\n<a href=\"#assert_assert_deepequal_actual_expected_message\"><code>assert.deepEqual()</code></a> implementation does not test the\n<a href=\"https://tc39.github.io/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots\"><code>[[Prototype]]</code></a> of objects, attached symbols, or\nnon-enumerable properties — for such checks, consider using\n<a href=\"#assert_assert_deepstrictequal_actual_expected_message\"><code>assert.deepStrictEqual()</code></a> instead. This can lead to some\npotentially surprising results. For example, the following example does not\nthrow an <code>AssertionError</code> because the properties on the <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions\"><code>RegExp</code></a> object are\nnot enumerable:</p>\n<pre><code class=\"lang-js\">// WARNING: This does not throw an AssertionError!\nassert.deepEqual(/a/gi, new Date());\n</code></pre>\n<p>An exception is made for <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map\"><code>Map</code></a> and <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set\"><code>Set</code></a>. Maps and Sets have their\ncontained items compared too, as expected.</p>\n<p>&quot;Deep&quot; equality means that the enumerable &quot;own&quot; properties of child objects\nare evaluated also:</p>\n<pre><code class=\"lang-js\">const assert = require(&#39;assert&#39;);\n\nconst obj1 = {\n  a: {\n    b: 1\n  }\n};\nconst obj2 = {\n  a: {\n    b: 2\n  }\n};\nconst obj3 = {\n  a: {\n    b: 1\n  }\n};\nconst obj4 = Object.create(obj1);\n\nassert.deepEqual(obj1, obj1);\n// OK, object is equal to itself\n\nassert.deepEqual(obj1, obj2);\n// AssertionError: { a: { b: 1 } } deepEqual { a: { b: 2 } }\n// values of b are different\n\nassert.deepEqual(obj1, obj3);\n// OK, objects are equal\n\nassert.deepEqual(obj1, obj4);\n// AssertionError: { a: { b: 1 } } deepEqual {}\n// Prototypes are ignored\n</code></pre>\n<p>If the values are not equal, an <code>AssertionError</code> is thrown with a <code>message</code>\nproperty set equal to the value of the <code>message</code> parameter. If the <code>message</code>\nparameter is undefined, a default error message is assigned.</p>\n"
        },
        {
          "textRaw": "assert.deepStrictEqual(actual, expected[, message])",
          "type": "method",
          "name": "deepStrictEqual",
          "meta": {
            "added": [
              "v1.2.0"
            ],
            "changes": [
              {
                "version": "v8.5.0",
                "pr-url": "https://github.com/nodejs/node/pull/15001",
                "description": "Error names and messages are now properly compared"
              },
              {
                "version": "v8.0.0",
                "pr-url": "https://github.com/nodejs/node/pull/12142",
                "description": "Set and Map content is also compared"
              },
              {
                "version": "v6.4.0, v4.7.1",
                "pr-url": "https://github.com/nodejs/node/pull/8002",
                "description": "Typed array slices are handled correctly now."
              },
              {
                "version": "v6.1.0",
                "pr-url": "https://github.com/nodejs/node/pull/6432",
                "description": "Objects with circular references can be used as inputs now."
              },
              {
                "version": "v5.10.1, v4.4.3",
                "pr-url": "https://github.com/nodejs/node/pull/5910",
                "description": "Handle non-`Uint8Array` typed arrays correctly."
              }
            ]
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`actual` {any} ",
                  "name": "actual",
                  "type": "any"
                },
                {
                  "textRaw": "`expected` {any} ",
                  "name": "expected",
                  "type": "any"
                },
                {
                  "textRaw": "`message` {any} ",
                  "name": "message",
                  "type": "any",
                  "optional": true
                }
              ]
            },
            {
              "params": [
                {
                  "name": "actual"
                },
                {
                  "name": "expected"
                },
                {
                  "name": "message",
                  "optional": true
                }
              ]
            }
          ],
          "desc": "<p>Generally identical to <code>assert.deepEqual()</code> with a few exceptions:</p>\n<ol>\n<li>Primitive values are compared using the <a href=\"https://tc39.github.io/ecma262/#sec-strict-equality-comparison\">Strict Equality Comparison</a>\n( <code>===</code> ). Set values and Map keys are compared using the <a href=\"https://tc39.github.io/ecma262/#sec-samevaluezero\">SameValueZero</a>\ncomparison. (Which means they are free of the <a href=\"#assert_caveats\">caveats</a>).</li>\n<li><a href=\"https://tc39.github.io/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots\"><code>[[Prototype]]</code></a> of objects are compared using\nthe <a href=\"https://tc39.github.io/ecma262/#sec-strict-equality-comparison\">Strict Equality Comparison</a> too.</li>\n<li><a href=\"https://tc39.github.io/ecma262/#sec-object.prototype.tostring\">Type tags</a> of objects should be the same.</li>\n<li><a href=\"https://developer.mozilla.org/en-US/docs/Glossary/Primitive#Primitive_wrapper_objects_in_JavaScript\">Object wrappers</a> are compared both as objects and unwrapped values.</li>\n</ol>\n<pre><code class=\"lang-js\">const assert = require(&#39;assert&#39;);\n\nassert.deepEqual({ a: 1 }, { a: &#39;1&#39; });\n// OK, because 1 == &#39;1&#39;\n\nassert.deepStrictEqual({ a: 1 }, { a: &#39;1&#39; });\n// AssertionError: { a: 1 } deepStrictEqual { a: &#39;1&#39; }\n// because 1 !== &#39;1&#39; using strict equality\n\n// The following objects don&#39;t have own properties\nconst date = new Date();\nconst object = {};\nconst fakeDate = {};\n\nObject.setPrototypeOf(fakeDate, Date.prototype);\n\nassert.deepEqual(object, fakeDate);\n// OK, doesn&#39;t check [[Prototype]]\nassert.deepStrictEqual(object, fakeDate);\n// AssertionError: {} deepStrictEqual Date {}\n// Different [[Prototype]]\n\nassert.deepEqual(date, fakeDate);\n// OK, doesn&#39;t check type tags\nassert.deepStrictEqual(date, fakeDate);\n// AssertionError: 2017-03-11T14:25:31.849Z deepStrictEqual Date {}\n// Different type tags\n\nassert.deepStrictEqual(new Number(1), new Number(2));\n// Fails because the wrapped number is unwrapped and compared as well.\nassert.deepStrictEqual(new String(&#39;foo&#39;), Object(&#39;foo&#39;));\n// OK because the object and the string are identical when unwrapped.\n</code></pre>\n<p>If the values are not equal, an <code>AssertionError</code> is thrown with a <code>message</code>\nproperty set equal to the value of the <code>message</code> parameter. If the <code>message</code>\nparameter is undefined, a default error message is assigned.</p>\n"
        },
        {
          "textRaw": "assert.doesNotThrow(block[, error][, message])",
          "type": "method",
          "name": "doesNotThrow",
          "meta": {
            "added": [
              "v0.1.21"
            ],
            "changes": [
              {
                "version": "v5.11.0, v4.4.5",
                "pr-url": "https://github.com/nodejs/node/pull/2407",
                "description": "The `message` parameter is respected now."
              },
              {
                "version": "v4.2.0",
                "pr-url": "https://github.com/nodejs/node/pull/3276",
                "description": "The `error` parameter can now be an arrow function."
              }
            ]
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`block` {Function} ",
                  "name": "block",
                  "type": "Function"
                },
                {
                  "textRaw": "`error` {RegExp|Function} ",
                  "name": "error",
                  "type": "RegExp|Function",
                  "optional": true
                },
                {
                  "textRaw": "`message` {any} ",
                  "name": "message",
                  "type": "any",
                  "optional": true
                }
              ]
            },
            {
              "params": [
                {
                  "name": "block"
                },
                {
                  "name": "error",
                  "optional": true
                },
                {
                  "name": "message",
                  "optional": true
                }
              ]
            }
          ],
          "desc": "<p>Asserts that the function <code>block</code> does not throw an error. See\n<a href=\"#assert_assert_throws_block_error_message\"><code>assert.throws()</code></a> for more details.</p>\n<p>When <code>assert.doesNotThrow()</code> is called, it will immediately call the <code>block</code>\nfunction.</p>\n<p>If an error is thrown and it is the same type as that specified by the <code>error</code>\nparameter, then an <code>AssertionError</code> is thrown. If the error is of a different\ntype, or if the <code>error</code> parameter is undefined, the error is propagated back\nto the caller.</p>\n<p>The following, for instance, will throw the <a href=\"errors.html#errors_class_typeerror\"><code>TypeError</code></a> because there is no\nmatching error type in the assertion:</p>\n<pre><code class=\"lang-js\">assert.doesNotThrow(\n  () =&gt; {\n    throw new TypeError(&#39;Wrong value&#39;);\n  },\n  SyntaxError\n);\n</code></pre>\n<p>However, the following will result in an <code>AssertionError</code> with the message\n&#39;Got unwanted exception (TypeError)..&#39;:</p>\n<pre><code class=\"lang-js\">assert.doesNotThrow(\n  () =&gt; {\n    throw new TypeError(&#39;Wrong value&#39;);\n  },\n  TypeError\n);\n</code></pre>\n<p>If an <code>AssertionError</code> is thrown and a value is provided for the <code>message</code>\nparameter, the value of <code>message</code> will be appended to the <code>AssertionError</code>\nmessage:</p>\n<pre><code class=\"lang-js\">assert.doesNotThrow(\n  () =&gt; {\n    throw new TypeError(&#39;Wrong value&#39;);\n  },\n  TypeError,\n  &#39;Whoops&#39;\n);\n// Throws: AssertionError: Got unwanted exception (TypeError). Whoops\n</code></pre>\n"
        },
        {
          "textRaw": "assert.equal(actual, expected[, message])",
          "type": "method",
          "name": "equal",
          "meta": {
            "added": [
              "v0.1.21"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`actual` {any} ",
                  "name": "actual",
                  "type": "any"
                },
                {
                  "textRaw": "`expected` {any} ",
                  "name": "expected",
                  "type": "any"
                },
                {
                  "textRaw": "`message` {any} ",
                  "name": "message",
                  "type": "any",
                  "optional": true
                }
              ]
            },
            {
              "params": [
                {
                  "name": "actual"
                },
                {
                  "name": "expected"
                },
                {
                  "name": "message",
                  "optional": true
                }
              ]
            }
          ],
          "desc": "<p>Tests shallow, coercive equality between the <code>actual</code> and <code>expected</code> parameters\nusing the <a href=\"https://tc39.github.io/ecma262/#sec-abstract-equality-comparison\">Abstract Equality Comparison</a> ( <code>==</code> ).</p>\n<pre><code class=\"lang-js\">const assert = require(&#39;assert&#39;);\n\nassert.equal(1, 1);\n// OK, 1 == 1\nassert.equal(1, &#39;1&#39;);\n// OK, 1 == &#39;1&#39;\n\nassert.equal(1, 2);\n// AssertionError: 1 == 2\nassert.equal({ a: { b: 1 } }, { a: { b: 1 } });\n//AssertionError: { a: { b: 1 } } == { a: { b: 1 } }\n</code></pre>\n<p>If the values are not equal, an <code>AssertionError</code> is thrown with a <code>message</code>\nproperty set equal to the value of the <code>message</code> parameter. If the <code>message</code>\nparameter is undefined, a default error message is assigned.</p>\n"
        },
        {
          "textRaw": "assert.fail(message)",
          "type": "method",
          "name": "fail",
          "meta": {
            "added": [
              "v0.1.21"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`actual` {any} ",
                  "name": "actual",
                  "type": "any"
                },
                {
                  "textRaw": "`expected` {any} ",
                  "name": "expected",
                  "type": "any"
                },
                {
                  "textRaw": "`message` {any} ",
                  "name": "message",
                  "type": "any",
                  "optional": true
                },
                {
                  "textRaw": "`operator` {string} **Default:** '!=' ",
                  "name": "operator",
                  "type": "string",
                  "desc": "**Default:** '!='",
                  "optional": true
                },
                {
                  "textRaw": "`stackStartFunction` {Function} **Default:** `assert.fail` ",
                  "name": "stackStartFunction",
                  "type": "Function",
                  "desc": "**Default:** `assert.fail`",
                  "optional": true
                }
              ]
            },
            {
              "params": [
                {
                  "name": "actual"
                },
                {
                  "name": "expected"
                },
                {
                  "name": "message",
                  "optional": true
                },
                {
                  "name": "operator",
                  "optional": true
                },
                {
                  "name": "stackStartFunction",
                  "optional": true
                }
              ]
            },
            {
              "params": [
                {
                  "name": "message"
                }
              ]
            }
          ],
          "desc": "<p>Throws an <code>AssertionError</code>. If <code>message</code> is falsy, the error message is set as\nthe values of <code>actual</code> and <code>expected</code> separated by the provided <code>operator</code>.\nIf just the two <code>actual</code> and <code>expected</code> arguments are provided, <code>operator</code> will\ndefault to <code>&#39;!=&#39;</code>. If <code>message</code> is provided only it will be used as the error\nmessage, the other arguments will be stored as properties on the thrown object.\nIf <code>stackStartFunction</code> is provided, all stack frames above that function will\nbe removed from stacktrace (see <a href=\"errors.html#errors_error_capturestacktrace_targetobject_constructoropt\"><code>Error.captureStackTrace</code></a>).</p>\n<pre><code class=\"lang-js\">const assert = require(&#39;assert&#39;);\n\nassert.fail(1, 2, undefined, &#39;&gt;&#39;);\n// AssertionError [ERR_ASSERTION]: 1 &gt; 2\n\nassert.fail(1, 2, &#39;fail&#39;);\n// AssertionError [ERR_ASSERTION]: fail\n\nassert.fail(1, 2, &#39;whoops&#39;, &#39;&gt;&#39;);\n// AssertionError [ERR_ASSERTION]: whoops\n</code></pre>\n<p><em>Note</em>: In the last two cases <code>actual</code>, <code>expected</code>, and <code>operator</code> have no\ninfluence on the error message.</p>\n<pre><code class=\"lang-js\">assert.fail();\n// AssertionError [ERR_ASSERTION]: Failed\n\nassert.fail(&#39;boom&#39;);\n// AssertionError [ERR_ASSERTION]: boom\n\nassert.fail(&#39;a&#39;, &#39;b&#39;);\n// AssertionError [ERR_ASSERTION]: &#39;a&#39; != &#39;b&#39;\n</code></pre>\n<p>Example use of <code>stackStartFunction</code> for truncating the exception&#39;s stacktrace:</p>\n<pre><code class=\"lang-js\">function suppressFrame() {\n  assert.fail(&#39;a&#39;, &#39;b&#39;, undefined, &#39;!==&#39;, suppressFrame);\n}\nsuppressFrame();\n// AssertionError [ERR_ASSERTION]: &#39;a&#39; !== &#39;b&#39;\n//     at repl:1:1\n//     at ContextifyScript.Script.runInThisContext (vm.js:44:33)\n//     ...\n</code></pre>\n"
        },
        {
          "textRaw": "assert.fail(actual, expected[, message[, operator[, stackStartFunction]]])",
          "type": "method",
          "name": "fail",
          "meta": {
            "added": [
              "v0.1.21"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`actual` {any} ",
                  "name": "actual",
                  "type": "any"
                },
                {
                  "textRaw": "`expected` {any} ",
                  "name": "expected",
                  "type": "any"
                },
                {
                  "textRaw": "`message` {any} ",
                  "name": "message",
                  "type": "any",
                  "optional": true
                },
                {
                  "textRaw": "`operator` {string} **Default:** '!=' ",
                  "name": "operator",
                  "type": "string",
                  "desc": "**Default:** '!='",
                  "optional": true
                },
                {
                  "textRaw": "`stackStartFunction` {Function} **Default:** `assert.fail` ",
                  "name": "stackStartFunction",
                  "type": "Function",
                  "desc": "**Default:** `assert.fail`",
                  "optional": true
                }
              ]
            },
            {
              "params": [
                {
                  "name": "actual"
                },
                {
                  "name": "expected"
                },
                {
                  "name": "message",
                  "optional": true
                },
                {
                  "name": "operator",
                  "optional": true
                },
                {
                  "name": "stackStartFunction",
                  "optional": true
                }
              ]
            }
          ],
          "desc": "<p>Throws an <code>AssertionError</code>. If <code>message</code> is falsy, the error message is set as\nthe values of <code>actual</code> and <code>expected</code> separated by the provided <code>operator</code>.\nIf just the two <code>actual</code> and <code>expected</code> arguments are provided, <code>operator</code> will\ndefault to <code>&#39;!=&#39;</code>. If <code>message</code> is provided only it will be used as the error\nmessage, the other arguments will be stored as properties on the thrown object.\nIf <code>stackStartFunction</code> is provided, all stack frames above that function will\nbe removed from stacktrace (see <a href=\"errors.html#errors_error_capturestacktrace_targetobject_constructoropt\"><code>Error.captureStackTrace</code></a>).</p>\n<pre><code class=\"lang-js\">const assert = require(&#39;assert&#39;);\n\nassert.fail(1, 2, undefined, &#39;&gt;&#39;);\n// AssertionError [ERR_ASSERTION]: 1 &gt; 2\n\nassert.fail(1, 2, &#39;fail&#39;);\n// AssertionError [ERR_ASSERTION]: fail\n\nassert.fail(1, 2, &#39;whoops&#39;, &#39;&gt;&#39;);\n// AssertionError [ERR_ASSERTION]: whoops\n</code></pre>\n<p><em>Note</em>: In the last two cases <code>actual</code>, <code>expected</code>, and <code>operator</code> have no\ninfluence on the error message.</p>\n<pre><code class=\"lang-js\">assert.fail();\n// AssertionError [ERR_ASSERTION]: Failed\n\nassert.fail(&#39;boom&#39;);\n// AssertionError [ERR_ASSERTION]: boom\n\nassert.fail(&#39;a&#39;, &#39;b&#39;);\n// AssertionError [ERR_ASSERTION]: &#39;a&#39; != &#39;b&#39;\n</code></pre>\n<p>Example use of <code>stackStartFunction</code> for truncating the exception&#39;s stacktrace:</p>\n<pre><code class=\"lang-js\">function suppressFrame() {\n  assert.fail(&#39;a&#39;, &#39;b&#39;, undefined, &#39;!==&#39;, suppressFrame);\n}\nsuppressFrame();\n// AssertionError [ERR_ASSERTION]: &#39;a&#39; !== &#39;b&#39;\n//     at repl:1:1\n//     at ContextifyScript.Script.runInThisContext (vm.js:44:33)\n//     ...\n</code></pre>\n"
        },
        {
          "textRaw": "assert.ifError(value)",
          "type": "method",
          "name": "ifError",
          "meta": {
            "added": [
              "v0.1.97"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`value` {any} ",
                  "name": "value",
                  "type": "any"
                }
              ]
            },
            {
              "params": [
                {
                  "name": "value"
                }
              ]
            }
          ],
          "desc": "<p>Throws <code>value</code> if <code>value</code> is truthy. This is useful when testing the <code>error</code>\nargument in callbacks.</p>\n<pre><code class=\"lang-js\">const assert = require(&#39;assert&#39;);\n\nassert.ifError(null);\n// OK\nassert.ifError(0);\n// OK\nassert.ifError(1);\n// Throws 1\nassert.ifError(&#39;error&#39;);\n// Throws &#39;error&#39;\nassert.ifError(new Error());\n// Throws Error\n</code></pre>\n"
        },
        {
          "textRaw": "assert.notDeepEqual(actual, expected[, message])",
          "type": "method",
          "name": "notDeepEqual",
          "meta": {
            "added": [
              "v0.1.21"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`actual` {any} ",
                  "name": "actual",
                  "type": "any"
                },
                {
                  "textRaw": "`expected` {any} ",
                  "name": "expected",
                  "type": "any"
                },
                {
                  "textRaw": "`message` {any} ",
                  "name": "message",
                  "type": "any",
                  "optional": true
                }
              ]
            },
            {
              "params": [
                {
                  "name": "actual"
                },
                {
                  "name": "expected"
                },
                {
                  "name": "message",
                  "optional": true
                }
              ]
            }
          ],
          "desc": "<p>Tests for any deep inequality. Opposite of <a href=\"#assert_assert_deepequal_actual_expected_message\"><code>assert.deepEqual()</code></a>.</p>\n<pre><code class=\"lang-js\">const assert = require(&#39;assert&#39;);\n\nconst obj1 = {\n  a: {\n    b: 1\n  }\n};\nconst obj2 = {\n  a: {\n    b: 2\n  }\n};\nconst obj3 = {\n  a: {\n    b: 1\n  }\n};\nconst obj4 = Object.create(obj1);\n\nassert.notDeepEqual(obj1, obj1);\n// AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } }\n\nassert.notDeepEqual(obj1, obj2);\n// OK: obj1 and obj2 are not deeply equal\n\nassert.notDeepEqual(obj1, obj3);\n// AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } }\n\nassert.notDeepEqual(obj1, obj4);\n// OK: obj1 and obj4 are not deeply equal\n</code></pre>\n<p>If the values are deeply equal, an <code>AssertionError</code> is thrown with a <code>message</code>\nproperty set equal to the value of the <code>message</code> parameter. If the <code>message</code>\nparameter is undefined, a default error message is assigned.</p>\n"
        },
        {
          "textRaw": "assert.notDeepStrictEqual(actual, expected[, message])",
          "type": "method",
          "name": "notDeepStrictEqual",
          "meta": {
            "added": [
              "v1.2.0"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`actual` {any} ",
                  "name": "actual",
                  "type": "any"
                },
                {
                  "textRaw": "`expected` {any} ",
                  "name": "expected",
                  "type": "any"
                },
                {
                  "textRaw": "`message` {any} ",
                  "name": "message",
                  "type": "any",
                  "optional": true
                }
              ]
            },
            {
              "params": [
                {
                  "name": "actual"
                },
                {
                  "name": "expected"
                },
                {
                  "name": "message",
                  "optional": true
                }
              ]
            }
          ],
          "desc": "<p>Tests for deep strict inequality. Opposite of <a href=\"#assert_assert_deepstrictequal_actual_expected_message\"><code>assert.deepStrictEqual()</code></a>.</p>\n<pre><code class=\"lang-js\">const assert = require(&#39;assert&#39;);\n\nassert.notDeepEqual({ a: 1 }, { a: &#39;1&#39; });\n// AssertionError: { a: 1 } notDeepEqual { a: &#39;1&#39; }\n\nassert.notDeepStrictEqual({ a: 1 }, { a: &#39;1&#39; });\n// OK\n</code></pre>\n<p>If the values are deeply and strictly equal, an <code>AssertionError</code> is thrown\nwith a <code>message</code> property set equal to the value of the <code>message</code> parameter. If\nthe <code>message</code> parameter is undefined, a default error message is assigned.</p>\n"
        },
        {
          "textRaw": "assert.notEqual(actual, expected[, message])",
          "type": "method",
          "name": "notEqual",
          "meta": {
            "added": [
              "v0.1.21"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`actual` {any} ",
                  "name": "actual",
                  "type": "any"
                },
                {
                  "textRaw": "`expected` {any} ",
                  "name": "expected",
                  "type": "any"
                },
                {
                  "textRaw": "`message` {any} ",
                  "name": "message",
                  "type": "any",
                  "optional": true
                }
              ]
            },
            {
              "params": [
                {
                  "name": "actual"
                },
                {
                  "name": "expected"
                },
                {
                  "name": "message",
                  "optional": true
                }
              ]
            }
          ],
          "desc": "<p>Tests shallow, coercive inequality with the <a href=\"https://tc39.github.io/ecma262/#sec-abstract-equality-comparison\">Abstract Equality Comparison</a>\n( <code>!=</code> ).</p>\n<pre><code class=\"lang-js\">const assert = require(&#39;assert&#39;);\n\nassert.notEqual(1, 2);\n// OK\n\nassert.notEqual(1, 1);\n// AssertionError: 1 != 1\n\nassert.notEqual(1, &#39;1&#39;);\n// AssertionError: 1 != &#39;1&#39;\n</code></pre>\n<p>If the values are equal, an <code>AssertionError</code> is thrown with a <code>message</code>\nproperty set equal to the value of the <code>message</code> parameter. If the <code>message</code>\nparameter is undefined, a default error message is assigned.</p>\n"
        },
        {
          "textRaw": "assert.notStrictEqual(actual, expected[, message])",
          "type": "method",
          "name": "notStrictEqual",
          "meta": {
            "added": [
              "v0.1.21"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`actual` {any} ",
                  "name": "actual",
                  "type": "any"
                },
                {
                  "textRaw": "`expected` {any} ",
                  "name": "expected",
                  "type": "any"
                },
                {
                  "textRaw": "`message` {any} ",
                  "name": "message",
                  "type": "any",
                  "optional": true
                }
              ]
            },
            {
              "params": [
                {
                  "name": "actual"
                },
                {
                  "name": "expected"
                },
                {
                  "name": "message",
                  "optional": true
                }
              ]
            }
          ],
          "desc": "<p>Tests strict inequality as determined by the <a href=\"https://tc39.github.io/ecma262/#sec-strict-equality-comparison\">Strict Equality Comparison</a>\n( <code>!==</code> ).</p>\n<pre><code class=\"lang-js\">const assert = require(&#39;assert&#39;);\n\nassert.notStrictEqual(1, 2);\n// OK\n\nassert.notStrictEqual(1, 1);\n// AssertionError: 1 !== 1\n\nassert.notStrictEqual(1, &#39;1&#39;);\n// OK\n</code></pre>\n<p>If the values are strictly equal, an <code>AssertionError</code> is thrown with a\n<code>message</code> property set equal to the value of the <code>message</code> parameter. If the\n<code>message</code> parameter is undefined, a default error message is assigned.</p>\n"
        },
        {
          "textRaw": "assert.ok(value[, message])",
          "type": "method",
          "name": "ok",
          "meta": {
            "added": [
              "v0.1.21"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`value` {any} ",
                  "name": "value",
                  "type": "any"
                },
                {
                  "textRaw": "`message` {any} ",
                  "name": "message",
                  "type": "any",
                  "optional": true
                }
              ]
            },
            {
              "params": [
                {
                  "name": "value"
                },
                {
                  "name": "message",
                  "optional": true
                }
              ]
            }
          ],
          "desc": "<p>Tests if <code>value</code> is truthy. It is equivalent to\n<code>assert.equal(!!value, true, message)</code>.</p>\n<p>If <code>value</code> is not truthy, an <code>AssertionError</code> is thrown with a <code>message</code>\nproperty set equal to the value of the <code>message</code> parameter. If the <code>message</code>\nparameter is <code>undefined</code>, a default error message is assigned.</p>\n<pre><code class=\"lang-js\">const assert = require(&#39;assert&#39;);\n\nassert.ok(true);\n// OK\nassert.ok(1);\n// OK\nassert.ok(false);\n// throws &quot;AssertionError: false == true&quot;\nassert.ok(0);\n// throws &quot;AssertionError: 0 == true&quot;\nassert.ok(false, &#39;it\\&#39;s false&#39;);\n// throws &quot;AssertionError: it&#39;s false&quot;\n</code></pre>\n"
        },
        {
          "textRaw": "assert.strictEqual(actual, expected[, message])",
          "type": "method",
          "name": "strictEqual",
          "meta": {
            "added": [
              "v0.1.21"
            ],
            "changes": []
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`actual` {any} ",
                  "name": "actual",
                  "type": "any"
                },
                {
                  "textRaw": "`expected` {any} ",
                  "name": "expected",
                  "type": "any"
                },
                {
                  "textRaw": "`message` {any} ",
                  "name": "message",
                  "type": "any",
                  "optional": true
                }
              ]
            },
            {
              "params": [
                {
                  "name": "actual"
                },
                {
                  "name": "expected"
                },
                {
                  "name": "message",
                  "optional": true
                }
              ]
            }
          ],
          "desc": "<p>Tests strict equality as determined by the <a href=\"https://tc39.github.io/ecma262/#sec-strict-equality-comparison\">Strict Equality Comparison</a>\n( <code>===</code> ).</p>\n<pre><code class=\"lang-js\">const assert = require(&#39;assert&#39;);\n\nassert.strictEqual(1, 2);\n// AssertionError: 1 === 2\n\nassert.strictEqual(1, 1);\n// OK\n\nassert.strictEqual(1, &#39;1&#39;);\n// AssertionError: 1 === &#39;1&#39;\n</code></pre>\n<p>If the values are not strictly equal, an <code>AssertionError</code> is thrown with a\n<code>message</code> property set equal to the value of the <code>message</code> parameter. If the\n<code>message</code> parameter is undefined, a default error message is assigned.</p>\n"
        },
        {
          "textRaw": "assert.throws(block[, error][, message])",
          "type": "method",
          "name": "throws",
          "meta": {
            "added": [
              "v0.1.21"
            ],
            "changes": [
              {
                "version": "v4.2.0",
                "pr-url": "https://github.com/nodejs/node/pull/3276",
                "description": "The `error` parameter can now be an arrow function."
              }
            ]
          },
          "signatures": [
            {
              "params": [
                {
                  "textRaw": "`block` {Function} ",
                  "name": "block",
                  "type": "Function"
                },
                {
                  "textRaw": "`error` {RegExp|Function} ",
                  "name": "error",
                  "type": "RegExp|Function",
                  "optional": true
                },
                {
                  "textRaw": "`message` {any} ",
                  "name": "message",
                  "type": "any",
                  "optional": true
                }
              ]
            },
            {
              "params": [
                {
                  "name": "block"
                },
                {
                  "name": "error",
                  "optional": true
                },
                {
                  "name": "message",
                  "optional": true
                }
              ]
            }
          ],
          "desc": "<p>Expects the function <code>block</code> to throw an error.</p>\n<p>If specified, <code>error</code> can be a constructor, <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions\"><code>RegExp</code></a>, or validation\nfunction.</p>\n<p>If specified, <code>message</code> will be the message provided by the <code>AssertionError</code> if\nthe block fails to throw.</p>\n<p>Validate instanceof using constructor:</p>\n<pre><code class=\"lang-js\">assert.throws(\n  () =&gt; {\n    throw new Error(&#39;Wrong value&#39;);\n  },\n  Error\n);\n</code></pre>\n<p>Validate error message using <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions\"><code>RegExp</code></a>:</p>\n<pre><code class=\"lang-js\">assert.throws(\n  () =&gt; {\n    throw new Error(&#39;Wrong value&#39;);\n  },\n  /value/\n);\n</code></pre>\n<p>Custom error validation:</p>\n<pre><code class=\"lang-js\">assert.throws(\n  () =&gt; {\n    throw new Error(&#39;Wrong value&#39;);\n  },\n  function(err) {\n    if ((err instanceof Error) &amp;&amp; /value/.test(err)) {\n      return true;\n    }\n  },\n  &#39;unexpected error&#39;\n);\n</code></pre>\n<p>Note that <code>error</code> can not be a string. If a string is provided as the second\nargument, then <code>error</code> is assumed to be omitted and the string will be used for\n<code>message</code> instead. This can lead to easy-to-miss mistakes:</p>\n<!-- eslint-disable no-restricted-syntax -->\n<pre><code class=\"lang-js\">// THIS IS A MISTAKE! DO NOT DO THIS!\nassert.throws(myFunction, &#39;missing foo&#39;, &#39;did not throw with expected message&#39;);\n\n// Do this instead.\nassert.throws(myFunction, /missing foo/, &#39;did not throw with expected message&#39;);\n</code></pre>\n"
        }
      ],
      "modules": [
        {
          "textRaw": "Caveats",
          "name": "caveats",
          "desc": "<p>For the following cases, consider using ES2015 <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is\"><code>Object.is()</code></a>,\nwhich uses the <a href=\"https://tc39.github.io/ecma262/#sec-samevaluezero\">SameValueZero</a> comparison.</p>\n<pre><code class=\"lang-js\">const a = 0;\nconst b = -a;\nassert.notStrictEqual(a, b);\n// AssertionError: 0 !== -0\n// Strict Equality Comparison doesn&#39;t distinguish between -0 and +0...\nassert(!Object.is(a, b));\n// but Object.is() does!\n\nconst str1 = &#39;foo&#39;;\nconst str2 = &#39;foo&#39;;\nassert.strictEqual(str1 / 1, str2 / 1);\n// AssertionError: NaN === NaN\n// Strict Equality Comparison can&#39;t be used to check NaN...\nassert(Object.is(str1 / 1, str2 / 1));\n// but Object.is() can!\n</code></pre>\n<p>For more information, see\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Equality_comparisons_and_sameness\">MDN&#39;s guide on equality comparisons and sameness</a>.</p>\n",
          "type": "module",
          "displayName": "Caveats"
        }
      ],
      "type": "module",
      "displayName": "Assert"
    }
  ]
}
