探索 Node.js 的测试运行器
¥Discovering Node.js's test runner
在本系列资源中,我们将发现如何使用 Node.js 的测试运行器来测试我们的代码。
¥In this series of resources, we will discover how to use Node.js's test runner to test our code.
什么是测试运行器?
¥What is a test runner?
测试运行器是一种允许你对代码运行测试的工具。它将执行你的测试并为你提供有关测试是通过还是失败的反馈。它还可以为你提供其他信息,例如代码覆盖率。
¥A test runner is a tool that allows you to run tests on your code. It will execute your tests and give you feedback on whether they pass or fail. It can also provide you with additional information such as code coverage.
Node.js 有许多可用的测试运行器,但我们将重点介绍 Node.js 附带的内置测试运行器。这很酷,因为你不需要安装任何其他依赖即可使用它。
¥There are many test runners available for Node.js, but we will focus on the built-in test runner that comes with Node.js. It's cool because you don't need to install any additional dependencies to use it.
为什么要测试你的代码?
¥Why test your code?
测试你的代码很重要,因为它允许你验证你的代码是否按预期工作。它可以帮助你在开发过程的早期发现错误,并确保你的代码可靠且可维护。
¥Testing your code is important because it allows you to verify that your code works as expected. It helps you catch bugs early in the development process and ensures that your code is reliable and maintainable.
使用 Node.js 运行测试
¥Running tests with Node.js
要使用 Node.js 运行测试,我们建议你阅读 测试运行器文档。
¥To run tests with Node.js, we recommend you to read the test runner documentation.