liveBook · Manning

Assertion

As explained in Web Components in Action

A software assertion is an executable check of an expected condition or property that signals failure when the check does not hold.

An assertion is a check that asks whether a condition or expected result is true. In a test, it can compare a function’s result with an expected value; a mismatch signals failure. section 13.2

assert.equal(doubleNum(2), 4);

This Chai assertion checks that doubling 2 returns the expected value, 4. section 13.2

How Web Components in Action covers it

How deep it goes
Defines assertions and illustrates expected-value checks, stopping short of explaining assertion-library internals.
Examples
Illustrates arithmetic, a number-doubling function, and slider component values and display state.
What you can do after
Apply Chai assertions to check function results and component state.
How it connects
Connects assertions with Chai, Mocha, browser automation, and testing.

Also explained in

Compare how 15 books explain assertion →

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.