Socket
Book a DemoInstallSign in
Socket

tape-jsx-extensions

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tape-jsx-extensions

Colection of tape assertion to work with JSX

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

tape-jsx-extensions

npm npm

Tape extensions collection to make React component easier to test.

Install

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

How to use

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

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 jsxExtensions from 'tape-jsx-extensions';
import MyComponent from '../MyComponent';

// extend tape with jsx extensions:
const test = addAssertions(tape, jsxExtensions);

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

	// compare output with the expected result:
    t.jsxEquals(result, <div className="box color-red"></div>);
    t.end();
});

Assert methods

Run tests

$ npm install
$ npm test

Keywords

test

FAQs

Package last updated on 06 Feb 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts