{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/jest/issues/6518","repository_url":"https://api.github.com/repos/facebook/jest","labels_url":"https://api.github.com/repos/facebook/jest/issues/6518/labels{/name}","comments_url":"https://api.github.com/repos/facebook/jest/issues/6518/comments","events_url":"https://api.github.com/repos/facebook/jest/issues/6518/events","html_url":"https://github.com/facebook/jest/issues/6518","id":334691114,"node_id":"MDU6SXNzdWUzMzQ2OTExMTQ=","number":6518,"title":"babel7 jest error","user":{"login":"budarin","id":8055157,"node_id":"MDQ6VXNlcjgwNTUxNTc=","avatar_url":"https://avatars2.githubusercontent.com/u/8055157?v=4","gravatar_id":"","url":"https://api.github.com/users/budarin","html_url":"https://github.com/budarin","followers_url":"https://api.github.com/users/budarin/followers","following_url":"https://api.github.com/users/budarin/following{/other_user}","gists_url":"https://api.github.com/users/budarin/gists{/gist_id}","starred_url":"https://api.github.com/users/budarin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/budarin/subscriptions","organizations_url":"https://api.github.com/users/budarin/orgs","repos_url":"https://api.github.com/users/budarin/repos","events_url":"https://api.github.com/users/budarin/events{/privacy}","received_events_url":"https://api.github.com/users/budarin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-06-21T23:11:59Z","updated_at":"2018-06-22T18:48:41Z","closed_at":null,"author_association":"NONE","body":"## 🐛 Bug Report\r\n\r\nI have worked my project with Babel 6.\r\nThen I moved it to Babel7 and got the error:\r\n```\r\n    D:\\Projects\\react-bootstrap-project\\src\\App.tsx:1\r\n    ({\"Object.<anonymous>\":function(module,exports,require,__dirname,__filename,global,jest){import React from 'react';\r\n                                                                                                    ^^^^^\r\n\r\n    SyntaxError: Unexpected identifier\r\n\r\n      1 | import React from 'react';\r\n      2 | import renderer from 'react-test-renderer';\r\n    > 3 | import App from './App';\r\n        | ^\r\n      4 |\r\n      5 | test('renders correctly', () => {\r\n      6 |     const tree = renderer.create(<App />).toJSON();\r\n\r\n      at ScriptTransformer._transformAndBuildScript (../node_modules/jest-runtime/build/script_transformer.js:402:17)\r\n      at Object.<anonymous> (App.test.js:3:1)\r\n```\r\njest.config.js\r\n\r\n```js\r\nconst config = {\r\n    rootDir: 'src',\r\n    preset: 'jest-puppeteer',\r\n    cacheDirectory: '../.tmp/jest',\r\n    coverageDirectory: '../.tmp/jest/coverage',\r\n    transform: {\r\n        '^.+\\\\.js$': '../config/jest/transformer.js',\r\n    },\r\n    testMatch: [\r\n        '**/__tests__/**/*.js?(x)',\r\n        '**/__tests__/**/*.ts?(x)',\r\n        '**/?(*.)+(spec|test).js?(x)',\r\n        '**/?(*.)+(spec|test).ts?(x)',\r\n    ],\r\n    moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx'],\r\n    moduleNameMapper: {\r\n        '\\\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':\r\n            '../config/jest/mocks/fileMock.js',\r\n        '\\\\.(css)$': '../config/jest/mocks/styleMock.js',\r\n    },\r\n    testPathIgnorePatterns: ['/node_modules/'],\r\n    globals: {},\r\n    notify: false,\r\n    notifyMode: 'failure',\r\n};\r\n\r\nmodule.exports = config;\r\n```\r\n/config/jest/transformer.js\r\n\r\n```js\r\nconst browserList = require('../browserList');\r\n\r\nconst config = {\r\n    babelrc: false,\r\n    presets: [\r\n        [\r\n            '@babel/preset-env',\r\n            {\r\n                loose: true,\r\n                debug: true,\r\n                modules: 'commonjs',\r\n                targets: {\r\n                    browsers: browserList,\r\n                },\r\n            },\r\n        ],\r\n        '@babel/preset-typescript',\r\n        '@babel/preset-react',\r\n    ],\r\n    plugins: [\r\n        '@babel/plugin-syntax-dynamic-import',\r\n        ['babel-plugin-lodash', { id: ['lodash', 'recompose'] }],\r\n        '@babel/plugin-transform-react-jsx-self',\r\n        '@babel/plugin-transform-react-jsx-source',\r\n        '@babel/plugin-proposal-class-properties',\r\n        '@babel/plugin-proposal-object-rest-spread',\r\n    ],\r\n};\r\n\r\nmodule.exports = require('babel-jest').createTransformer(config);\r\n```\r\n\r\n## To Reproduce\r\n\r\nrun tests\r\n\r\n## Expected behavior\r\n\r\nsuccessful tests\r\n\r\n## Link to repl or repo (highly encouraged)\r\n\r\nLink to my [repository](https://github.com/budarin/react-bootstrap-project)\r\n\r\n## Run `npx envinfo --preset jest`\r\n\r\n```bash\r\n  System:\r\n    OS: Windows 7\r\n    CPU: x64 AMD FX(tm)-6300 Six-Core Processor\r\n  Binaries:\r\n    Yarn: 1.6.0 - C:\\Program Files (x86)\\Yarn\\bin\\yarn.CMD\r\n    npm: 6.1.0 - C:\\Program Files\\nodejs\\npm.CMD\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/facebook/jest/issues/comments/399543849","html_url":"https://github.com/facebook/jest/issues/6518#issuecomment-399543849","issue_url":"https://api.github.com/repos/facebook/jest/issues/6518","id":399543849,"node_id":"MDEyOklzc3VlQ29tbWVudDM5OTU0Mzg0OQ==","user":{"login":"budarin","id":8055157,"node_id":"MDQ6VXNlcjgwNTUxNTc=","avatar_url":"https://avatars2.githubusercontent.com/u/8055157?v=4","gravatar_id":"","url":"https://api.github.com/users/budarin","html_url":"https://github.com/budarin","followers_url":"https://api.github.com/users/budarin/followers","following_url":"https://api.github.com/users/budarin/following{/other_user}","gists_url":"https://api.github.com/users/budarin/gists{/gist_id}","starred_url":"https://api.github.com/users/budarin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/budarin/subscriptions","organizations_url":"https://api.github.com/users/budarin/orgs","repos_url":"https://api.github.com/users/budarin/repos","events_url":"https://api.github.com/users/budarin/events{/privacy}","received_events_url":"https://api.github.com/users/budarin/received_events","type":"User","site_admin":false},"created_at":"2018-06-22T18:48:41Z","updated_at":"2018-06-22T18:48:41Z","author_association":"NONE","body":"solved - it needs to point transformer to .ts & .tsx modules\r\n```js\r\n'^.+\\\\.js$': '../config/jest/transformer.js',\r\n```"}}
{"actor":{"display_login":"budarin"}}