What does this library "assert" does?
https://deno.land/std@0.215.0/assert/mod.ts
What does it do in this example?
https://docs.deno.com/runtime/manual/advanced/jsx_dom/deno_dom#basic-example
Using deno-dom with Deno | Deno Docs
deno-dom is an implementation of DOM and HTML
2 Replies
The
assert
library in Deno is part of the standard library's assertions module, which provides developers with a set of common assertion functions for writing tests. These functions are used to verify that certain conditions are true during the execution of tests. The assert
function itself is a simple "truthy" assertion that can be used to assert any value that can be inferred as true.
In the context of the example you've provided, the assert
function is not directly used. The example from the documentation under the section "Using deno-dom with Deno" does not include the assert
function. Instead, it discusses the deno-dom
library, which is an implementation of the DOM and HTML parser in Deno. The example likely demonstrates how to use deno-dom
to parse HTML and manipulate the resulting DOM structure, but it does not involve the assert
function from the assertions module.
If you're looking for examples of how the assert
function is used, the documentation provides the following example:
In this example, the assert
function is used within a test case to verify that the provided expressions are truthy. If any of the expressions evaluated to false, the test would fail. 🦕It asserts that
document
is truthy, which in this case means it's not null
If the HTML is invalid, parseFromString()
returns null
IIRC