Skip to content

jameslnewell/react-testutils-render

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-testutils-render

A lite wrapper for shallow rendering React components.

Installation

npm install --save react-testutils-render

Usage

it('should increment the count by 1 when called', () => {
  const rendered = render(<Counter/>);
  rendered.component.handleIncrement();
  expect(rendered.component.state).to.have.property('count', 1);
});

it('should render the count', () => {
  expect(render(<Counter/>).element).to.deep.equal(
    <div>
      Count: {0}.
      <button onClick={() => {}}>Increment</button>
    </div>
  );
});

Methods

render(element) : object

Render the element as a virtual-dom tree, one level deep.

  • element- A React virtual-dom element

License

The MIT License (MIT)

Copyright (c) 2015 James Newell

About

A lite wrapper for shallow rendering React components.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published