Extend Chai with support for asserting JSX equality & contents with support for Preact Components.
(Heavily) inspired by jsx-chai.
; /** @jsx h */;;chai;// check if two JSX DOMs are deeply equal:todeep;// check if a given JSX DOM contains the given fragment:to;
Note: in environments like Karma where chai is available as a global,
preact-jsx-chaiwill automatically register itself on import. Don't worry, though, this plugin is smart enough to avoid registering itself multiple times.
There are a few global options available to customize how
preact-jsx-chai asserts over VNodes.
||Function||auto||Override the detection of values as being JSX VNodes.|
;optionsfunctions = false;// or:;jsxChaioptionsfunctions = false;
Assertions are supported for both functional and classical components.
Typically, JSX assertions follow a pattern where the component to be tested is passed to
expect() with any props necessary, and the expected DOM state is passed to
.eql() (or its alias
// Supports both functional and classical componentsconst Link =<a class="link" href='/'+href>Link: text </a>;to;