What is an assertion? What does the assertion in the program mean, let's take a question step-by-step exploration
Assertion that we believe that a particular point in the program Boolean expression is True
An example is:
I believe you are right, then let others judge you are right or wrong, and finally I get the result.
Okay, get to the chase.
Assert-ASSERT (the following parameters I will not introduce, directly on code)
1 assert (value[, message])2 assert (Value,meesage)3 //The two formats are the same, the ' [] ' in the program represents an optional section, ' <> ' stands for the required part. 4 5 Assert.deepequal (Actual, expected[, message])
6 Assert.deepstrictequal (Actual, expected[, message])
7 Assert.doesnotthrow (block[, error][, message])
8 Assert.equal (Actual, expected[, message])
9 assert.fail (message)
Ten Assert.fail (Actual, expected[, message[, operator[, Stackstartfunction]])
One Assert.iferror (value)
A Assert.notdeepequal (Actual, expected[, message])
- Assert.notdeepstrictequal (Actual, expected[, message])
- Assert.notequal (Actual, expected[, message])
the Assert.notstrictequal (Actual, expected[, message])
- Assert.ok (value[, message])
- Assert.strictequal (Actual, expected[, message])
-Assert.throws (block[, error][, message])
ASSERT (value[, message])
Const ASSERT = require (' assert '); ASSERT (true, Console.log (' * * * print out information) ");
Assert.deepequal (Actual, expected[, message])
Tests only the enumerable properties of itself, without testing the object's prototype, connector, or non-enumerable properties (these cases are used assert.deepStrictEqual()
). For example, the following example is not thrown AssertionError
because RegExp
the object's properties are not enumerable:
Prototype: the original type
Connector: "+"
Enumerable self-Properties:
Console.log (Object.keys (var_name))
Enumerable self-properties of the output
Non-enumerable properties: The comparison point for enumerable and non-enumerated types is: Can it be used for. In traversal to
var New Number (); for (var in num) {
Console.log ("Num." + Pro + "=" + Num[pro]);}
//fortest.js
//non-enumerable JS base type, return nullvarnum =NewNumber (); for(varProinchnum) {Console.log ("Num." + Pro + "=" +Num[pro]);}functionPerson () { This. Name = "KXY";} Person.prototype={constructor:person, job:"Student",};varKxy =NewPerson (); Object.defineproperty (Kxy,"Sex", {value:"Female", Enumerable:false});//non-enumerable sex, mainly because of enumerable (true enumeration) for(varProinchkxy) {Console.log ("Kxy." + Pro + "=" +Kxy[pro]);}//enumerable self-PropertiesConsole.log (Object.keys (KXY));
node. JS-Assertion