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-cheeriodoes not implementvisibleandhiddenassertions. This is due to known limitations in the upstreamcheerioproject. Feel free to suggest workarounds, or even better, submit PRs.chai-cheeriocannot identify an element by the original selector that was used to find it, which means that for.existassertion errors, it will simply outputexpectedelementto existorexpectedelementnot to exist, unlikechai-jquery, which outputsexpected#foonot to existto identify the element. This is becausechai-jquerymakes use of jQuery’s deprecated.selectorproperty, whilecheeriodoes not have this property. Again, feel free to suggest workarounds or submit PRs.chai-cheeriodoes not implement thefocusassertion.
Contributing
To run the test suite, run npm install (requires
Node.js to be installed on your system), and then:
npm test