Learning nodejs-02

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.