jasmine-react-matchers

1.0.2 • Public • Published

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

Package Sidebar

Install

npm i jasmine-react-matchers

Weekly Downloads

3

Version

1.0.2

License

MIT

Last publish

Collaborators

  • jstejada