This package has been deprecated

Author message:

Package renamed `expect-jsx`, see https://github.com/algolia/expect-jsx/blob/master/CHANGELOG.md

expect-to-equal-jsx

1.1.4 • Public • Published

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:

Readme

Keywords

none

Package Sidebar

Install

npm i expect-to-equal-jsx

Weekly Downloads

1

Version

1.1.4

License

MIT

Last publish

Collaborators

  • vvo