chai-jsx
v1.0.1
Published
JSX React Element assertions for chai
Downloads
578
Maintainers
Readme
chai-jsx
JSX React Element assertions for chai. Thin wrapper around react-element-to-jsx-string.
Compare different React elements:
expect(<Component />).jsx.to.equal(<Component />);
expect(<Component />).jsx.to.not.equal(<Component prop={value} />);
expect(<Component />).jsx.to.not.equal(<OtherComponent />);
expect(<Component />).jsx.to.not.equal(<div />);
expect(<Component><div /></Component>).jsx.to.equal(<Component><div /></Component>);
expect(<Component><div /></Component>).jsx.to.not.equal(<Component><span /></Component>);
Installation
This is a addon plugin for the Chai Assertion Library. Install via npm.
npm install chai-jsx
Plugin
Use this plugin as you would all other Chai plugins.
var chai = require('chai')
, chaiJsx = require('chai-jsx');
chai.use(chaiJsx);