1.0.2 • Published 9 years ago

jasmine-react-matchers v1.0.2

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

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