0.1.3 • Published 5 years ago

abstract-react-component-jest-mount v0.1.3

Weekly downloads
17
License
Apache-2.0
Repository
github
Last release
5 years ago

Abstract React Component Jest Mount

Mount Abstract React Components for Jest Testing

Usage

yarn add abstract-react-component-jest-mount --dev
interface IProps {
  message: string
}

class SomeClass extends React.Component<IProps> {

  public static defaultProps: Partial<IProps> = {
    message: 'Hello World!'
  }

  mode = 'default'

  state = {
    foo: 'bar'
  }

  type: string

  constructor(props) {
    super(props)

    props.setRoot(this)

    this.type = 'derived'
  }

  render() {
    return <div>{this.props.message}</div>
  }

}

const { ref, root, unmount } = mount(<SomeClass />)
  • ref The React reference to the component mounted.
  • root The this scope to the component mounted.
  • unmount Clean up the component from the DOM. Required if multiple tests use mount.
0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago