karma-chai-equal-jsx
Disclaimer: This repo is a work in progress. For now, I'd recommend importing the chai-equal-jsx plugin into your test bundle directly, like so.
Adds equalJSX
and includeJSX
methods to chai assertions. Uses Algolia's react-element-to-jsx-string under the hood.
Installation
npm install -D karma-chai-equal-jsx
Setup
// karma.conf.jsmodule { config
Usage
The following tests are all passing:
Expect
Component {} // equalJSXto;to; tonot;tonot; // includeJSXto;to; tonot;tonot;
Should
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;