1.1.4 • Published 9 years ago

expect-to-equal-jsx v1.1.4

Weekly downloads
1
License
MIT
Repository
github
Last release
9 years ago

expect-to-equal-jsx

Version Build Status License Downloads

toEqualJSX for mjackson/expect.

It uses algolia/react-element-to-jsx-string in the background to turn React elements into formatted strings.

Table of Contents generated with DocToc

Setup

npm install expect-to-equal-jsx --save[-dev]

Usage

import React from 'react';
import expect from 'expect';
import toEqualJSX from 'expect-to-equal-jsx';

expect.extend({toEqualJSX});

expect(<div/>).toEqualJSX(<div/>);
expect(<div a="1" b="2"/>).toEqualJSX(<div/>);
// Error: Expected '<div\n  a="1"\n  b="2"\n/>' to equal '<div />'

When using mochajs/mocha, this will look like this:

Screenshot when using mocha

A note about functions

toEqualJSX will not check for function references, it only checks that if a function was expected somewhere, there's also a function in the actual data.

It's your responsibility to then unit test those functions.

Test

npm test
npm run test:watch

Build

npm run build
npm run build:watch

Thanks

To the people pointing me in the right directions like:

1.1.4

9 years ago

1.1.3

9 years ago

1.1.2

9 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago