Cheerio assertions for the Chai assertion library

Downloads in past


1.0.08 years ago8 years agoMinified + gzip package size for chai-cheerio in KB


Build Status
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.


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:
  1. chai-cheerio does not implement visible and hidden
assertions. This is due to known limitations in the upstream cheerio project. Feel free to suggest workarounds, or even better, submit PRs.
  1. 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 output expected element to exist or expected element not to exist, unlike chai-jquery, which outputs expected #foo not to exist to identify the element. This is because chai-jquery makes use of jQuery's deprecated .selector property, while cheerio does not have this property. Again, feel free to suggest workarounds or submit PRs.
  1. chai-cheerio does not implement the focus assertion.


To run the test suite, run npm install (requires Node.js to be installed on your system), and then:
npm test