Assertion: Learn Java when learning assertions, but have been used very little, node also has
var assert = require (' Assert ') console.info (' ..... Start app ... '); var actual = 1;var expect = ' 1 ' var a;//determine if True assert (A, ' is not valid '); Assert.ok (0, ' isn't effective ');//arg[0] is the true value, arg[1] expectation, arg[2] Optional error message//equal and notequal are through = = and! =, Comparisons are type conversions, such as 1== ' 1 ' for true//strictequal and notstrictequal through = = and!==, such as 1=== ' 1 ' for falseassert.equal (actual, Actual, ' Excption message:value!== ... ') assert.strictequal (actual, expect, ' excption message:value!=== '); Assert.notequal ( Actual, expect, ' excption message:value = = ... ') assert.notstrictequal (actual, expect, ' excption message:value=== ... ') Console.info (' ..... end app .....);
Several have not been tested, used to say.
Deep comparison, comparing objects, arrays ....Assert.deepequal (actual, expected, [message])Assert.notdeepequal (actual, expected, [message]to determine whether a piece of code throws an exception, this
Assert.throws (block, [ERROR], [message])
This article is from the "Sky Sea Wide" blog, please be sure to keep this source http://ether007.blog.51cto.com/8912105/1411274