{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/jest/issues/6938","repository_url":"https://api.github.com/repos/facebook/jest","labels_url":"https://api.github.com/repos/facebook/jest/issues/6938/labels{/name}","comments_url":"https://api.github.com/repos/facebook/jest/issues/6938/comments","events_url":"https://api.github.com/repos/facebook/jest/issues/6938/events","html_url":"https://github.com/facebook/jest/issues/6938","id":356495832,"node_id":"MDU6SXNzdWUzNTY0OTU4MzI=","number":6938,"title":"babel7 object destructing fails in test cases","user":{"login":"hannadrehman","id":23405869,"node_id":"MDQ6VXNlcjIzNDA1ODY5","avatar_url":"https://avatars3.githubusercontent.com/u/23405869?v=4","gravatar_id":"","url":"https://api.github.com/users/hannadrehman","html_url":"https://github.com/hannadrehman","followers_url":"https://api.github.com/users/hannadrehman/followers","following_url":"https://api.github.com/users/hannadrehman/following{/other_user}","gists_url":"https://api.github.com/users/hannadrehman/gists{/gist_id}","starred_url":"https://api.github.com/users/hannadrehman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hannadrehman/subscriptions","organizations_url":"https://api.github.com/users/hannadrehman/orgs","repos_url":"https://api.github.com/users/hannadrehman/repos","events_url":"https://api.github.com/users/hannadrehman/events{/privacy}","received_events_url":"https://api.github.com/users/hannadrehman/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-09-03T12:57:30Z","updated_at":"2018-09-03T15:58:06Z","closed_at":"2018-09-03T13:44:45Z","author_association":"NONE","body":"<!-- Love Jest? Please consider supporting our collective: 👉  https://opencollective.com/jest/donate -->\r\n\r\n## 🐛 Bug Report\r\n\r\nI have a react project which I recently migrated to bable7. everything works fine but when I tried to run my test cases it started failing.  all of the other issue I was able to resolve except this one.  \r\nit seems like `object destructuring` seems to be failing when running `jest`\r\n\r\nhere is my component that fails.  \r\n\r\n```\r\nimport React from 'react';\r\nimport PropTypes from 'prop-types';\r\nimport { Input } from 'antd';\r\n\r\nconst { Search } = Input;  // jest fails here....\r\n\r\nclass TextBoxWithButton extends React.Component {\r\n  static propTypes = {\r\n    placeholder: PropTypes.string.isRequired,\r\n    onAction: PropTypes.func.isRequired,\r\n    buttonText: PropTypes.string,\r\n  }\r\n\r\n  static defaultProps = {\r\n    buttonText: '',\r\n  }\r\n\r\n  constructor(props) {\r\n    super(props);\r\n    this.state = {\r\n      value: '',\r\n    };\r\n  }\r\n\r\n  onSubmit = (value) => {\r\n    const { onAction } = this.props;\r\n    this.setState({\r\n      value: '',\r\n    });\r\n    onAction(value);\r\n  }\r\n\r\n  handleChange = (ev) => {\r\n    this.setState({\r\n      value: ev.target.value,\r\n    });\r\n  }\r\n\r\n  render() {\r\n    const { placeholder, buttonText } = this.props;\r\n    const { value } = this.state;\r\n    return (\r\n      <React.Fragment>\r\n        <Search\r\n          placeholder={placeholder}\r\n          onSearch={this.onSubmit}\r\n          enterButton={buttonText}\r\n          value={value}\r\n          onChange={this.handleChange}\r\n        />\r\n      </React.Fragment>\r\n\r\n    );\r\n  }\r\n}\r\n\r\nexport default TextBoxWithButton;\r\n\r\n```\r\n\r\nhere is my `.babelrc`\r\n\r\n```\r\n{\r\n  \"presets\": [\r\n    [\"@babel/preset-env\", {  \"modules\": false, \"useBuiltIns\":\"usage\"  }],\r\n    \"@babel/preset-react\"\r\n  ],\r\n  \"plugins\": [\r\n    \"react-hot-loader/babel\",\r\n    \"@babel/plugin-proposal-object-rest-spread\",\r\n    \"@babel/plugin-proposal-class-properties\",\r\n    \"@babel/plugin-syntax-dynamic-import\",\r\n    [\"import\", {  \"libraryName\": \"antd\", \"libraryDirectory\": \"es\", \"style\": false }],\r\n    [\r\n      \"module-resolver\",\r\n      {\r\n        \"root\": [\r\n          \"./src\"\r\n        ],\r\n        \"alias\": {\r\n          \"App\": \"./src/App\",\r\n          \"Common\": \"./src/App/Common\",\r\n          \"Elements\": \"./src/App/Elements\",\r\n          \"Router\": \"./src/App/Router\",\r\n          \"Constants\": \"./src/Constants\",\r\n          \"Services\": \"./src/Services\",\r\n          \"Store\": \"./src/Store\",\r\n          \"Styles\": \"./src/Styles\",\r\n          \"Assets\": \"./src/Assets\"\r\n        }\r\n      }\r\n    ]\r\n  ],\r\n  \"env\": {\r\n    \"test\": {\r\n      \"presets\": [\r\n        [\"@babel/preset-env\"],\r\n        \"@babel/preset-react\"\r\n      ],\r\n      \"plugins\": [\r\n        \"@babel/plugin-transform-modules-commonjs\",\r\n        \"@babel/plugin-proposal-object-rest-spread\",\r\n        \"@babel/plugin-proposal-class-properties\",\r\n        \"@babel/plugin-syntax-dynamic-import\",\r\n        [\"import\", {  \"libraryName\": \"antd\", \"style\": \"css\" }]\r\n      ]\r\n    }\r\n  }\r\n}\r\n\r\n```\r\nhere is my jest.config.js\r\n\r\n```\r\nconst jestConfig = {\r\n  verbose: true,\r\n  moduleNameMapper: {\r\n    '\\\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '<rootDir>/__mocks__/fileMock.js',\r\n    '\\\\.(css|scss)$': '<rootDir>/__mocks__/styleMock.js',\r\n  },\r\n  transform: {\r\n    '^.+\\\\.jsx?$': '<rootDir>/node_modules/babel-jest',\r\n    '^.+\\\\.js?$': '<rootDir>/node_modules/babel-jest',\r\n    '\\\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '<rootDir>/__mocks__/fileMock.js',\r\n  },\r\n  moduleFileExtensions: [\r\n    'js',\r\n    'jsx',\r\n  ],\r\n  unmockedModulePathPatterns: [\r\n    '<rootDir>/node_modules/react/',\r\n    '<rootDir>/node_modules/react-dom/',\r\n  ],\r\n  moduleDirectories: [\r\n    'node_modules',\r\n  ],\r\n  transformIgnorePatterns: [\r\n    '/node_modules/',\r\n  ],\r\n  coveragePathIgnorePatterns: [\r\n    '/node_modules/',\r\n  ],\r\n  modulePathIgnorePatterns: [\r\n    '/node_modules/',\r\n  ],\r\n  collectCoverage: true,\r\n  coverageReporters: [\r\n    'json',\r\n    'lcov',\r\n    'text',\r\n  ],\r\n};\r\n\r\nmodule.exports = jestConfig // eslint-disable-line\r\n\r\n```\r\n\r\nhere is my package.json\r\n\r\n```\r\n{\r\n  \"name\": \"react-app\",\r\n  \"version\": \"1.0.0\",\r\n  \"main\": \"index.jsx\",\r\n  \"license\": \"MIT\",\r\n  \"scripts\": {\r\n    \"start\": \"npm run start:dev\",\r\n    \"start:dev\": \"npm run dev-server --   --mode development --env.NODE_ENV=development --env.PROXY_ORIGIN=http://localhost:3000\",\r\n    \"start:stage\": \"npm run dev-server --  --mode development --env.NODE_ENV=development --env.PROXY_ORIGIN=http://localhost:3001\",\r\n    \"start:dev-min\": \"npm run start:dev -- --env.MIN_STATS=true\",\r\n    \"start:analyze-speed\": \"npm run start:dev -- --env.addons=speedmeasure\",\r\n    \"build\": \"npm run test && webpack --optimize-minimize --mode production --env.NODE_ENV=production --env.PUBLIC_PATH=/\",\r\n    \"build:analyze-bundle\": \"npm run build -- --env.addons=bundleanalyzer\",\r\n    \"build:analyze-buddy\": \"npm run build -- --env.addons=bundlebuddy\",\r\n    \"dev-server\": \"webpack-dev-server --inline\",\r\n    \"test:watch\": \"npm run test -- --watchAll\",\r\n    \"test\": \"export BABEL_ENV=test&&NODE_ENV=test&& jest\",\r\n    \"profile\": \"webpack --env.NODE_ENV=production --progress -c --profile --json  > stats.json\"\r\n  },\r\n  \"description\": \"this tool will be used to book consultation for clients.\",\r\n  \"dependencies\": {\r\n    \"@babel/polyfill\": \"^7.0.0\",\r\n    \"antd\": \"^3.9.0\",\r\n    \"axios\": \"^0.18.0\",\r\n    \"moment\": \"^2.22.2\",\r\n    \"prop-types\": \"^15.6.2\",\r\n    \"react\": \"^16.4.2\",\r\n    \"react-asynchronous-component\": \"^1.0.2\",\r\n    \"react-dom\": \"^16.4.2\",\r\n    \"react-hot-loader\": \"^4.3.5\",\r\n    \"react-redux\": \"^5.0.7\",\r\n    \"react-router-dom\": \"^4.3.1\",\r\n    \"redux\": \"^4.0.0\",\r\n    \"regenerator-runtime\": \"^0.12.1\",\r\n    \"redux-saga\": \"^0.16.0\"\r\n  },\r\n  \"devDependencies\": {\r\n    \"@babel/core\": \"^7.0.0\",\r\n    \"@babel/plugin-proposal-class-properties\": \"^7.0.0\",\r\n    \"@babel/plugin-proposal-object-rest-spread\": \"^7.0.0\",\r\n    \"@babel/plugin-syntax-dynamic-import\": \"^7.0.0\",\r\n    \"@babel/plugin-transform-modules-commonjs\": \"^7.0.0\",\r\n    \"@babel/preset-env\": \"^7.0.0\",\r\n    \"@babel/preset-react\": \"^7.0.0\",\r\n    \"antd-scss-theme-plugin\": \"^1.0.7\",\r\n    \"autoprefixer\": \"^9.1.3\",\r\n    \"babel-core\": \"7.0.0-bridge.0\",\r\n    \"babel-eslint\": \"^8.2.6\",\r\n    \"babel-jest\": \"^23.4.2\",\r\n    \"babel-loader\": \"^8.0.0\",\r\n    \"babel-plugin-import\": \"^1.8.0\",\r\n    \"babel-plugin-module-resolver\": \"^3.1.1\",\r\n    \"bundle-buddy-webpack-plugin\": \"^0.3.0\",\r\n    \"clean-webpack-plugin\": \"^0.1.19\",\r\n    \"css-loader\": \"^1.0.0\",\r\n    \"cssnano\": \"^4.1.0\",\r\n    \"enzyme\": \"^3.5.0\",\r\n    \"enzyme-adapter-react-16\": \"^1.3.1\",\r\n    \"error-overlay-webpack-plugin\": \"^0.1.5\",\r\n    \"eslint\": \"^5.5.0\",\r\n    \"eslint-config-airbnb\": \"^17.1.0\",\r\n    \"eslint-import-resolver-babel-module\": \"^5.0.0-beta.1\",\r\n    \"eslint-loader\": \"^2.1.0\",\r\n    \"eslint-plugin-css-modules\": \"^2.8.1\",\r\n    \"eslint-plugin-import\": \"^2.14.0\",\r\n    \"eslint-plugin-jsx-a11y\": \"^6.1.1\",\r\n    \"eslint-plugin-react\": \"^7.11.1\",\r\n    \"extract-text-webpack-plugin\": \"*\",\r\n    \"fast-sass-loader\": \"^1.4.6\",\r\n    \"file-loader\": \"^1.1.11\",\r\n    \"glob\": \"^7.1.3\",\r\n    \"hard-source-webpack-plugin\": \"^0.12.0\",\r\n    \"html-webpack-plugin\": \"^3.2.0\",\r\n    \"jest\": \"^23.5.0\",\r\n    \"jest-cli\": \"^23.5.0\",\r\n    \"less-loader\": \"^4.1.0\",\r\n    \"mini-css-extract-plugin\": \"^0.4.2\",\r\n    \"node-sass\": \"^4.9.3\",\r\n    \"optimize-css-assets-webpack-plugin\": \"^5.0.1\",\r\n    \"postcss-loader\": \"^3.0.0\",\r\n    \"purify-css\": \"^1.2.5\",\r\n    \"purifycss-webpack\": \"^0.7.0\",\r\n    \"sass-loader\": \"^7.1.0\",\r\n    \"speed-measure-webpack-plugin\": \"^1.2.2\",\r\n    \"style-loader\": \"^0.22.1\",\r\n    \"system-bell-webpack-plugin\": \"*\",\r\n    \"uglifyjs-webpack-plugin\": \"^1.3.0\",\r\n    \"webpack\": \"^4.17.1\",\r\n    \"webpack-bundle-analyzer\": \"^2.13.1\",\r\n    \"webpack-bundle-tracker\": \"^0.3.0\",\r\n    \"webpack-cli\": \"^3.1.0\",\r\n    \"webpack-dev-server\": \"^3.1.7\",\r\n    \"webpack-manifest-plugin\": \"^2.0.3\",\r\n    \"webpack-merge\": \"^4.1.4\"\r\n  }\r\n}\r\n```\r\nhere is the jest test runner fail output\r\n\r\n```\r\n FAIL  src/App/Elements/__tests__/index.spec.js\r\n  ● Test suite failed to run\r\n\r\n    ReferenceError: Input is not defined\r\n\r\n      3 | import { Input } from 'antd';\r\n      4 |\r\n    > 5 | const { Search } = Input;\r\n        |                    ^\r\n      6 |\r\n      7 | class TextBoxWithButton extends React.Component {\r\n      8 |   static propTypes = {\r\n\r\n      at Object.Input (src/App/Elements/TextBox/TextBoxWithButton/TextBoxWithButton.component.jsx:5:20)\r\n      at Object.<anonymous> (src/App/Elements/index.js:2:1)\r\n      at Object.<anonymous> (src/App/Elements/__tests__/index.spec.js:1:1)\r\n```\r\n\r\n\r\n\r\n## To Reproduce\r\n\r\ninstall `bable7`\r\ninstall `babel-core = 7.0.0-bridge.0`\r\nuse object destructring in any component. \r\nand run jest \r\n\r\n## Expected behavior\r\n\r\njest should be able to use `babel-jest` and transform  es6 and process it.\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/facebook/jest/issues/comments/418151590","html_url":"https://github.com/facebook/jest/issues/6938#issuecomment-418151590","issue_url":"https://api.github.com/repos/facebook/jest/issues/6938","id":418151590,"node_id":"MDEyOklzc3VlQ29tbWVudDQxODE1MTU5MA==","user":{"login":"hannadrehman","id":23405869,"node_id":"MDQ6VXNlcjIzNDA1ODY5","avatar_url":"https://avatars3.githubusercontent.com/u/23405869?v=4","gravatar_id":"","url":"https://api.github.com/users/hannadrehman","html_url":"https://github.com/hannadrehman","followers_url":"https://api.github.com/users/hannadrehman/followers","following_url":"https://api.github.com/users/hannadrehman/following{/other_user}","gists_url":"https://api.github.com/users/hannadrehman/gists{/gist_id}","starred_url":"https://api.github.com/users/hannadrehman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hannadrehman/subscriptions","organizations_url":"https://api.github.com/users/hannadrehman/orgs","repos_url":"https://api.github.com/users/hannadrehman/repos","events_url":"https://api.github.com/users/hannadrehman/events{/privacy}","received_events_url":"https://api.github.com/users/hannadrehman/received_events","type":"User","site_admin":false},"created_at":"2018-09-03T15:58:06Z","updated_at":"2018-09-03T15:58:06Z","author_association":"NONE","body":"@thymikee i have not mocked `antd` anywhere and `.babelrc` is also added in my post. the strange thing is it was working fine on `babel6` . after upgrading to `babel7`, this issue started after that."}}
{"actor":{"display_login":"hannadrehman"}}