react-social-login icon indicating copy to clipboard operation
react-social-login copied to clipboard

Test with Jest failing

Open Kif11 opened this issue 5 years ago • 3 comments

I'm trying to test one of my components with Jest that use SocialButton. Set up is exactly in provided example.

it('renders correctly', () => {
  const wrapper = shallow(<SocialButton />);
  console.log(wrapper.html());
});

I'm getting this error. Any ideas what can be wrong?

TypeError: Cannot read property 'render' of undefined

I think, this is happening because react-social-login/dist/social-login.js in NPM distribution is minified.

Kif11 avatar Mar 05 '19 09:03 Kif11

Hmm, I build the project without webpack Uglify plugging. It is failing on the last line of this snippet:

/**
 * React Higher Order Component handling social login for multiple providers.
 * @param {Element} WrappedComponent
 * @constructor
 */
var SocialLogin = function SocialLogin(WrappedComponent) {
  var _class, _temp;

  return _temp = _class = function (_Component) {
    _inherits(SocialLogin, _Component);

    function SocialLogin(props) {
      _classCallCheck(this, SocialLogin);

      var _this = _possibleConstructorReturn(this, (SocialLogin.__proto__ || Object.getPrototypeOf(SocialLogin)).call(this, props));

      _this.isStateless = !WrappedComponent.prototype.render;

Kif11 avatar Mar 05 '19 10:03 Kif11

@deepakaggarwal7 any ideas?

Kif11 avatar Mar 10 '19 07:03 Kif11

There are a few issues mentioning that the component doesn't work as functional component as prototype isn't supported. Will check more.

deepakaggarwal7 avatar Mar 02 '21 09:03 deepakaggarwal7