Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ref doesn't properly render with Enzyme. #3694

Closed
andrewplummer opened this issue Jul 10, 2019 · 3 comments

Comments

Projects
None yet
2 participants
@andrewplummer
Copy link

commented Jul 10, 2019

Bug Report

It seems that the Ref HOC doesn't play well with Enzyme. Using shallow will result in a warning and render or mount will throw an error.

Steps

import React from 'react';
import { configure, shallow, render, mount } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import { Ref, Container } from 'semantic-ui-react';

configure({ adapter: new Adapter() });

function Foo() {
  const ref = React.createRef();
  return (
    <Ref innerRef={ref}>
      <Container>Content</Container>
    </Ref>
  );
}

describe('foo', () => {
  it('blahblah', () => {
    const wrapper = shallow(<Foo />);
  });
});

Expected Result

Element should properly be wrapped/rendered/mounted.

Actual Result

Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

Version

0.87.3

@triage-new-issues triage-new-issues bot added the triage label Jul 10, 2019

@welcome

This comment has been minimized.

Copy link

commented Jul 10, 2019

👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you've completed all the fields in the issue template so we can best help.

We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

@layershifter

This comment has been minimized.

Copy link
Member

commented Jul 10, 2019

https://codesandbox.io/s/dank-sunset-qz4cp

What version of Enzyme you're using? Can you please provide a repro?

image

image

We testing all our components with Enzyme and will be really strange to have such issue.

@andrewplummer

This comment has been minimized.

Copy link
Author

commented Jul 10, 2019

Apologies! I had confirmed several times and this was not working and now it's working great! I may have unintentionally upgraded some libs or something in the meantime. At any rate I've switched to using the Ref HOC and everything works as intended! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.