This package has been deprecated

Author message:

I am no longer maintaining this package. Contact me if you wish to take over maintaining it.

tape-jsx-includes

1.1.0 • Public • Published

tape-jsx-includes

Tape extension to assert one jsx string includes another

npm npm

Tape extension to assert one jsx string includes another.

tape-jsx-includes uses react-element-to-jsx-string to compare two components' rendered output.

Install

$ npm install --save-dev extend-tape
$ npm install --save-dev tape-jsx-includes

How to use

Testing React components is very easy with tape + tape-jsx-includes:

const MyComponent = function ({color}) {
    const className = `box color-${color}`;
    return (
        <div className={className}></div>
    );
};
import {createRenderer} from 'react-addons-test-utils';
import tape from 'tape';
import addAssertions from 'extend-tape';
import jsxIncludes from 'tape-jsx-includes';
import MyComponent from '../MyComponent';

// extend tape with jsxIncludes assertion:
const test = addAssertions(tape, {jsxIncludes});

test('MyComponent is included', (t) => {
  const renderer = createRenderer();
  renderer.render(<MyComponent color="red" />);
  const result = renderer.getRenderOutput();

  t.jsxIncludes(result, <div><div><div className="box color-red"></div></div></div>);
  t.end();
});

Run tests

$ npm install
$ npm test

Readme

Keywords

Package Sidebar

Install

npm i tape-jsx-includes

Weekly Downloads

1

Version

1.1.0

License

MIT

Last publish

Collaborators

  • joerter