How to use react-shallow-renderer - 1 common examples

To help you get started, we’ve selected a few react-shallow-renderer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github davidmarkclements / react-functional / test / index.js View on Github external
const component = ({name}, cmp) => {
    instance1 = cmp
    pass('render function called')
    return (<div>{name}</div>)
  }

  const options = {
    componentWillMount: (props, refs, cmp) =&gt; {
      instance2 = cmp
      pass('componentWillMount called')
    }
  }

  
  const Component = functional(component, options)
  const rendered = render()
  const {type, props:{children}} = rendered

  {
    const actual = type
    const expected = 'div'
    is(actual, expected, 'div element rendered')
  }

  {
    const actual = children
    const expected = 'test'
    is(actual, expected, 'prop passed through')
  }

  {
    const actual = instance1

react-shallow-renderer

React package for shallow rendering.

MIT
Latest version published 3 years ago

Package Health Score

71 / 100
Full package analysis

Popular react-shallow-renderer functions