liveBook · Manning

Assertion library

As explained in Web Components in Action

An assertion library is a software library that provides operations for checking expected conditions in automated tests.

An assertion library supplies questions whose answers should be true. In browser testing, Chai lets you express expectations such as `assert.equal(1 + 2, 3)` and compare function results. section 13.2

Assertions form the checking layer alongside Mocha’s test suites and Selenium’s browser automation. Instead of hardcoding both sides, compare component state, attributes, calculated styles, or function results. section 13.2

Testing a slider component

A slider test can assert its initial value, reflected attribute, and thumb position: `assert.equal(slider.value, 50)`. Further assertions verify JavaScript updates and clamp values such as 110 and −10 to configured bounds.

How Web Components in Action covers it

How deep it goes
Defines expected truth and demonstrates equality checks, without detailing assertion-library internals.
Examples
Uses arithmetic, a number-doubling function, and slider values, attributes, thumb positions, and boundary cases.
What it assumes
Assumes basic automated-testing context while introducing assertions from the idea of expected true answers.
What you can do after
Apply assertions via Chai to verify function results and component behavior in automated tests.
How it connects
Connects assertions with Chai, Mocha, Selenium, browser automation, and component testing.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Web Components in Action. The section links point to the parts of the book it draws on.