Skip to content

ckknight/chai-jsx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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>);

Check for inclusion of child elements:

expect(<Parent><Child /></Parent>).jsx.to.include(<Child />);

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);

About

JSX React Element assertions for chai

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published