liveBook · Manning

Mocha

As explained in Web Components in Action

Mocha is a JavaScript test framework that provides facilities for defining and running tests.

Mocha is a JavaScript test framework for organizing and running tests. It groups individual tests into suites and provides setup and teardown hooks. section 13.2

In Web Component Tester, Mocha handles test organization while Selenium launches browsers and Chai supplies assertions. Together they support browser-based component testing. section 13.2

Testing a slider component

A suite can check a slider’s initial value, attribute, and rendered thumb position, then test JavaScript updates and out-of-range values.

How Web Components in Action covers it

How deep it goes
Demonstrates suite and test structure, assertions, component setup, and failing boundary cases without exploring framework internals.
Examples
Uses arithmetic assertions, a number-doubling function, and a slider component with value, rendering, and bounds tests.
What it assumes
Assumes JavaScript and browser components while defining assertions, suites, hooks, and automated browser testing.
What you can do after
Apply it via Mocha to organize component tests and verify behavior through assertions running in automated browsers.
How it connects
Connects test suites and assertions with Web Component Tester, Selenium, Chai, browser automation, and Web Components.

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.