{"action":"created","issue":{"url":"https://api.github.com/repos/fedosejev/react-essentials/issues/8","labels_url":"https://api.github.com/repos/fedosejev/react-essentials/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/fedosejev/react-essentials/issues/8/comments","events_url":"https://api.github.com/repos/fedosejev/react-essentials/issues/8/events","html_url":"https://github.com/fedosejev/react-essentials/issues/8","id":107381088,"number":8,"title":"Chapter 8: Testing React components (pages 129-131).","user":{"login":"matthewlynch","id":3437234,"avatar_url":"https://avatars.githubusercontent.com/u/3437234?v=3","gravatar_id":"","url":"https://api.github.com/users/matthewlynch","html_url":"https://github.com/matthewlynch","followers_url":"https://api.github.com/users/matthewlynch/followers","following_url":"https://api.github.com/users/matthewlynch/following{/other_user}","gists_url":"https://api.github.com/users/matthewlynch/gists{/gist_id}","starred_url":"https://api.github.com/users/matthewlynch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthewlynch/subscriptions","organizations_url":"https://api.github.com/users/matthewlynch/orgs","repos_url":"https://api.github.com/users/matthewlynch/repos","events_url":"https://api.github.com/users/matthewlynch/events{/privacy}","received_events_url":"https://api.github.com/users/matthewlynch/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-09-20T09:14:10Z","updated_at":"2015-11-26T09:56:21Z","closed_at":"2015-09-20T09:49:07Z","body":"Hi, \r\n\r\nWhen running `npm test` after finishing `Header-test.js` an error is thrown:\r\n\r\n```\r\n$ npm test\r\n\r\n> snapterest@1.0.0 test /path/to/snapterest\r\n> jest\r\n\r\nUsing Jest CLI v0.5.5\r\n PASS  source/utils/__tests__/TweetUtils-test.js (0.017s)\r\n PASS  source/utils/__tests__/CollectionUtils-test.js (0.022s)\r\n FAIL  source/components/__tests__/Header-test.js \r\n● Runtime Error\r\nSyntaxError: /path/to/snapterest/source/components/__tests__/Header-test.js: Unexpected token <\r\n  at Object.exports.runInContext (vm.js:43:16)\r\n  at JSDomEnvironment.runSourceText (/path/to/snapterest/node_modules/jest-cli/src/JSDomEnvironment.js:86:8)\r\n  at Object.runContentWithLocalBindings (/path/to/snapterest/node_modules/jest-cli/src/lib/utils.js:498:17)\r\n  at Loader._execModule (/path/to/snapterest/node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:236:9)\r\n  at Loader.requireModule (/path/to/snapterest/node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:905:12)\r\n  at jasmineTestRunner (/path/to/snapterest/node_modules/jest-cli/src/jasmineTestRunner/jasmineTestRunner.js:284:16)\r\n  at /path/to/snapterest/node_modules/jest-cli/src/TestRunner.js:375:12\r\n\r\n1 test failed, 2 tests passed (3 total)\r\nRun time: 1.011s\r\nnpm ERR! Test failed.  See above for more details.\r\n```\r\n\r\nAfter some digging around I found this link: https://facebook.github.io/jest/docs/tutorial-react.html#setup. I needed to install ` babel-jest` and add this to my `package.json` file: \r\n```\r\n\"jest\": {\r\n    \"scriptPreprocessor\": \"<rootDir>/node_modules/babel-jest\",\r\n    \"unmockedModulePathPatterns\": [\r\n      \"<rootDir>/node_modules/react\"\r\n    ]\r\n  }\r\n```\r\n\r\nLeaving this here for anyone else who might run into this problem.\r\n\r\nUsing \r\nnode: 4.1.0\r\nnpm: 2.14.3\r\nreact: 0.14.0-rc1\r\njest: 0.5.5 (i upgraded to 0.5.7 and got the same error before updating my `package.json` file)"},"comment":{"url":"https://api.github.com/repos/fedosejev/react-essentials/issues/comments/159864114","html_url":"https://github.com/fedosejev/react-essentials/issues/8#issuecomment-159864114","issue_url":"https://api.github.com/repos/fedosejev/react-essentials/issues/8","id":159864114,"user":{"login":"backslash112","id":5343215,"avatar_url":"https://avatars.githubusercontent.com/u/5343215?v=3","gravatar_id":"","url":"https://api.github.com/users/backslash112","html_url":"https://github.com/backslash112","followers_url":"https://api.github.com/users/backslash112/followers","following_url":"https://api.github.com/users/backslash112/following{/other_user}","gists_url":"https://api.github.com/users/backslash112/gists{/gist_id}","starred_url":"https://api.github.com/users/backslash112/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/backslash112/subscriptions","organizations_url":"https://api.github.com/users/backslash112/orgs","repos_url":"https://api.github.com/users/backslash112/repos","events_url":"https://api.github.com/users/backslash112/events{/privacy}","received_events_url":"https://api.github.com/users/backslash112/received_events","type":"User","site_admin":false},"created_at":"2015-11-26T09:56:21Z","updated_at":"2015-11-26T09:56:21Z","body":"Thank you, @matthewlynch  This works for me!! a little different with you.  ^0^\r\n``` \r\n\"jest\": {\r\n    \"scriptPreprocessor\": \"<rootDir>/node_modules/babel-jest\",\r\n    \"unmockedModulePathPatterns\": [\r\n      \"<rootDir>/node_modules/react\",\r\n      \"<rootDir>/node_modules/react-dom\",\r\n      \"<rootDir>/node_modules/react-addons-test-utils\",\r\n      \"<rootDir>/node_modules/fbjs\"\r\n    ]\r\n  },\r\n```\r\n\r\nBTW, using\r\nnode: 4.1.1\r\nnpm: 3.4.1\r\nreact: 0.14.3\r\njest: 0.8.0"}}