VinceMalone
9/2/2018 - 8:37 PM

mock component helper

import React, { Component } from 'react';
import PropTypes from 'prop-types';

/**
 * jest.mock('components/Foo', () => mockComponent('Foo'));
 */
export const mockComponent = ComponentName =>
  class extends Component {
    static propTypes = new Proxy(
      {},
      {
        get: () => PropTypes.any,
      },
    );

    render() {
      return <ComponentName {...this.props} />;
    }
  };