在nodejs中使用断言模块? [英] Assert module use in nodejs?

查看:172
本文介绍了在nodejs中使用断言模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好我正在阅读节点官方文档,我看过Assert模块,但是不明白它的用法,到目前为止我的结论就像是某些语言的(try-catch)官方文档上的例子对我来说还不够理解这个模块,你能帮帮我吗?

Hello everyone I was reading node official documentation, and I've seen the "Assert" module, but don't understand its use, my conclutions up to now are that is like the (try--catch) of some languages, the examples on official documentation are not enough for me to understand the module, could you guys help me please?

推荐答案

这些会用于单元测试。

These would be used for unit testing.


此模块用于为应用程序编写单元测试,您可以使用require('assert')访问它。
http://nodejs.org/api/assert.html

单元测试的目标是测试代码的各个单元。
例如,要测试一个函数,可以给它输入并知道期望的输出。这将隔离该功能,因此您可以确保代码的其他部分没有错误。

The goal of a unit test is to test individual units of your code. For example, to test a function, you give it the input and know what output to expect. This will isolate that function so you can be sure there is not an error in other parts of your code.

这篇关于在nodejs中使用断言模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆