chai-equal-jsx
Adds equalJSX
and includeJSX
methods to chai assertions. Uses Algolia's react-element-to-jsx-string under the hood.
Installation
npm install -D chai-equal-jsx
Setup
;; chai;
Usage
The following tests are all passing:
Expect
Component {} // equalJSXto;to; tonot;tonot; // includeJSXto;to; tonot;tonot;
Should
chai; Component {} // equalJSX<div />should;<TestComponent />should; <div />shouldnot;<TestComponent />shouldnot; // includeJSX<div><TestComponent /></div>should;<div><TestComponent /><span /></div>should; <TestComponent />shouldnot;<div><span /><TestComponent /></div>shouldnot;
See test/index.js
for usage in context.