From the course: Node.js: Testing and Code Quality

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Assertions for correctness

Assertions for correctness

- [Instructor] Determining if actual output matches the expected is a requirement for testing if a system is working correctly. Assertion libraries are the solution, but what are they? As you may recall, an assertion validates the correctness of a unit of code. Assertions declare that a given predicate is going to be Boolean true. For example, here's an assertion that 'dog' is strictly equal to 'cat.' In this case, the assertion will throw an error because the string literals do not match. All right. So what's an assertion library? An assertion library is a collection of assertions. Typically many more than what's in Node.js's assert module. They support comparisons of many different types of language structures like objects or rays, Booleans, numbers and more. Like a framework, assertion libraries provide an API, or in some cases multiple APIs for developers to create predicates. The APIs provide interfaces and…

Contents