Core ModulesLesson 33Free preview
Assert Module
This lesson is part of Node.js · All levels
Summary
The assert module provides a simple assertion function to verify that a condition is correct during testing. If the condition turns out to be wrong, the assertion will throw the AssertionError so that the problem is quickly detected. This module is useful for lightweight test units without the need for additional frameworks.
Key points
- Check the truth value
- Compare the value with the === strictly
- It checks that a function does throw an error
- Assertion failure will throw AssertionError that stops execution
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.