Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

jasmine-react-matchers

jstejada25MIT1.0.2

Custom matchers to test React Elements

react, reactjs, react-matchers, jasmine-react-matchers, jasmine, jasmine matchers, jasmine react matchers, testing react, test, compare react elements, virtual dom, compare virtual dom, virtual-dom, test react elements

readme

Jasmine React Matchers

Custom Jasmine matchers to assert and compare React Elements.

Install

npm install jasmine-react-matchers --save

Description

It makes sure that each the elements have the same:

  • type
  • props
  • children

It ignores the key and any other property associated with the Element.

Usage

import ReactMatchers from 'jasmine-react-matchers';

describe('MyTest', ()=> {
    beforeEach(()=> {
      // Add here
      jasmine.addMatchers(ReactMatchers));
    }

  it('does something', ()=> {
    const actual = <div className="C">T</div>;
    const expected = <div className="C">T</div>;
    // Use here
    expect(actual).toEqualElement(expected);
  });
});

Refer to test/ for more examples.

Development

Run tests:

npm test

License

MIT