{"action":"closed","issue":{"url":"https://api.github.com/repos/airbnb/enzyme/issues/1232","repository_url":"https://api.github.com/repos/airbnb/enzyme","labels_url":"https://api.github.com/repos/airbnb/enzyme/issues/1232/labels{/name}","comments_url":"https://api.github.com/repos/airbnb/enzyme/issues/1232/comments","events_url":"https://api.github.com/repos/airbnb/enzyme/issues/1232/events","html_url":"https://github.com/airbnb/enzyme/issues/1232","id":263161549,"node_id":"MDU6SXNzdWUyNjMxNjE1NDk=","number":1232,"title":"ShallowWrapper instance of Stateless React component returns null","user":{"login":"mykhailo-riabokon","id":10687640,"node_id":"MDQ6VXNlcjEwNjg3NjQw","avatar_url":"https://avatars1.githubusercontent.com/u/10687640?v=4","gravatar_id":"","url":"https://api.github.com/users/mykhailo-riabokon","html_url":"https://github.com/mykhailo-riabokon","followers_url":"https://api.github.com/users/mykhailo-riabokon/followers","following_url":"https://api.github.com/users/mykhailo-riabokon/following{/other_user}","gists_url":"https://api.github.com/users/mykhailo-riabokon/gists{/gist_id}","starred_url":"https://api.github.com/users/mykhailo-riabokon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mykhailo-riabokon/subscriptions","organizations_url":"https://api.github.com/users/mykhailo-riabokon/orgs","repos_url":"https://api.github.com/users/mykhailo-riabokon/repos","events_url":"https://api.github.com/users/mykhailo-riabokon/events{/privacy}","received_events_url":"https://api.github.com/users/mykhailo-riabokon/received_events","type":"User","site_admin":false},"labels":[{"id":704653953,"node_id":"MDU6TGFiZWw3MDQ2NTM5NTM=","url":"https://api.github.com/repos/airbnb/enzyme/labels/v3%20expected%20difference","name":"v3 expected difference","color":"c2e0c6","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":24,"created_at":"2017-10-05T15:09:02Z","updated_at":"2018-07-05T20:32:29Z","closed_at":"2018-07-05T20:32:29Z","author_association":"CONTRIBUTOR","body":"Hello,\r\n\r\nAfter update to enzyme 3 and React 16, ShallowWrapper `instance()` works a bit different. For Stateless React component it returns `null`. Please check test example bellow:\r\n```javascript\r\nimport { shallow } from 'enzyme';\r\nimport React from 'react';\r\n\r\nfunction Stateless({ name }) {\r\n\treturn <div>{name}</div>;\r\n}\r\n\r\nclass Statefull extends React.Component {\r\n\trender() {\r\n\t\treturn <div>{this.props.name}</div>;\r\n\t}\r\n}\r\n\r\ndescribe('enzyme 3 with React 16', () => {\r\n\tconst props = {\r\n\t\tname: 'Test',\r\n\t};\r\n\r\n\tdescribe('Stateless component', () => {\r\n\t\ttest('shallow wrapper instance should not be null', () => {\r\n\t\t\tconst wrapper = shallow(<Stateless {...props} />);\r\n\t\t\tconst instance = wrapper.instance();\r\n\r\n\t\t    expect(instance).not.toBe(null);\r\n\t\t});\r\n\t});\r\n\r\n\tdescribe('Statefull component', () => {\r\n\t\ttest('shallow wrapper instance should not be null', () => {\r\n\t\t\tconst wrapper = shallow(<Statefull {...props} />);\r\n\t\t\tconst instance = wrapper.instance();\r\n\r\n\t\t    expect(instance).not.toBe(null);\r\n\t\t});\r\n\t});\r\n});\r\n```\r\nAs a result I have an error in next test `enzyme with React 16 › Stateless component › shallow wrapper instance should not be null`. Also, these tests are passed with enzyme 3 + enzyme-adapter-react-15 + React 15.\r\n\r\nsetup\r\n```javascript\r\nconst Enzyme = require('enzyme');\r\nconst Adapter = require('enzyme-adapter-react-16');\r\n\r\nEnzyme.configure({ adapter: new Adapter() });\r\n```\r\n\r\npackage.json\r\n```javascript\r\n{\r\n    ...\r\n    \"dependencies\": {\r\n      ...\r\n      \"react\": \"^16.0.0\",\r\n      \"react-dom\": \"^16.0.0\",\r\n      ...\r\n    },\r\n    \"devDependencies\": {\r\n      ...\r\n      \"enzyme\": \"^3.1.0\",\r\n      \"enzyme-adapter-react-16\": \"^1.0.1\",\r\n      \"jest\": \"^20.0.4\",\r\n      \"react-test-renderer\": \"^16.0.0\",\r\n      ...\r\n    },\r\n    ...\r\n}\r\n```\r\n\r\nSo, is it configuration issue, or something else? \r\n\r\nThanks for any help."}}
{"actor":{"display_login":"ljharb"}}