chai-cheerio
chai-cheerio is an extension to the chai assertion library that
provides a set of Cheerio-specific assertions. It was forked from chai-jquery
,
and modified to work with cheerio
instead of jQuery.
In the following documentation, all links to chai-jquery
point directly to the version
that chai-cheerio
is based on.
Usage
As this is a port of chai-jquery
, I recommend that you check out the original
project’s README
for usage information.
Here, I will highlight the differences in assertion capabilities between
chai-cheerio
and chai-jquery
:
chai-cheerio
does not implementvisible
andhidden
assertions. This is due to known limitations in the upstreamcheerio
project. Feel free to suggest workarounds, or even better, submit PRs.chai-cheerio
cannot identify an element by the original selector that was used to find it, which means that for.exist
assertion errors, it will simply outputexpected
element
to exist
orexpected
element
not to exist
, unlikechai-jquery
, which outputsexpected
#foo
not to exist
to identify the element. This is becausechai-jquery
makes use of jQuery’s deprecated.selector
property, whilecheerio
does not have this property. Again, feel free to suggest workarounds or submit PRs.chai-cheerio
does not implement thefocus
assertion.
Contributing
To run the test suite, run npm install
(requires
Node.js to be installed on your system), and then:
npm test