chai-jsx

JSX React Element assertions for chai

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
chai-jsx
1501.0.17 years ago7 years agoMinified + gzip package size for chai-jsx in KB

Readme

chai-jsx
JSX React Element assertions for chai. Thin wrapper around react-element-to-jsx-string.
NPM version Build Status
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);