{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/jest/issues/334","repository_url":"https://api.github.com/repos/facebook/jest","labels_url":"https://api.github.com/repos/facebook/jest/issues/334/labels{/name}","comments_url":"https://api.github.com/repos/facebook/jest/issues/334/comments","events_url":"https://api.github.com/repos/facebook/jest/issues/334/events","html_url":"https://github.com/facebook/jest/issues/334","id":69997288,"number":334,"title":"How to test with Jest when I'm using webpack","user":{"login":"iroy2000","id":487520,"avatar_url":"https://avatars.githubusercontent.com/u/487520?v=3","gravatar_id":"","url":"https://api.github.com/users/iroy2000","html_url":"https://github.com/iroy2000","followers_url":"https://api.github.com/users/iroy2000/followers","following_url":"https://api.github.com/users/iroy2000/following{/other_user}","gists_url":"https://api.github.com/users/iroy2000/gists{/gist_id}","starred_url":"https://api.github.com/users/iroy2000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iroy2000/subscriptions","organizations_url":"https://api.github.com/users/iroy2000/orgs","repos_url":"https://api.github.com/users/iroy2000/repos","events_url":"https://api.github.com/users/iroy2000/events{/privacy}","received_events_url":"https://api.github.com/users/iroy2000/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":24,"created_at":"2015-04-22T01:46:36Z","updated_at":"2016-04-13T04:47:06Z","closed_at":null,"body":"I'm using webpack and react, everything works fine until I do the unit test with Jest.\r\n\r\nIn one of my js files I have \r\n\r\n```js\r\nrequire('style/components/example_app.scss');\r\n````\r\n\r\nAnd it said\r\nCannot find module 'style/pages/example_index.scss'\r\n\r\n\r\nThe following is my __webpack config__\r\n\r\n```js\r\nresolve: {\r\n        extensions: ['', '.js', '.jsx'],\r\n        root: [path.join(__dirname, 'src'), path.join(__dirname, 'assets')]\r\n    },\r\n```\r\n\r\nThe following is my configuration in __package.json__\r\n\r\n```js\r\n    \"jest\": {\r\n        \"scriptPreprocessor\": \"<rootDir>/preprocessor.js\",\r\n        \"unmockedModulePathPatterns\": [\"<rootDir>/node_modules/react\"],\r\n        \"testFileExtensions\": [\r\n            \"js\",\r\n            \"jsx\"\r\n        ],\r\n        \"moduleFileExtensions\": [\r\n            \"js\",\r\n            \"json\",\r\n            \"jsx\"\r\n        ]\r\n    },\r\n```\r\n\r\nThe following is my __folder structure__\r\n\r\n\\__tests\\__ /   ( host all my test )\r\n\r\nsrc / js /  ( host all my js )\r\n\r\n   \r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/facebook/jest/issues/comments/209226063","html_url":"https://github.com/facebook/jest/issues/334#issuecomment-209226063","issue_url":"https://api.github.com/repos/facebook/jest/issues/334","id":209226063,"user":{"login":"chrislloyd","id":718,"avatar_url":"https://avatars.githubusercontent.com/u/718?v=3","gravatar_id":"","url":"https://api.github.com/users/chrislloyd","html_url":"https://github.com/chrislloyd","followers_url":"https://api.github.com/users/chrislloyd/followers","following_url":"https://api.github.com/users/chrislloyd/following{/other_user}","gists_url":"https://api.github.com/users/chrislloyd/gists{/gist_id}","starred_url":"https://api.github.com/users/chrislloyd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrislloyd/subscriptions","organizations_url":"https://api.github.com/users/chrislloyd/orgs","repos_url":"https://api.github.com/users/chrislloyd/repos","events_url":"https://api.github.com/users/chrislloyd/events{/privacy}","received_events_url":"https://api.github.com/users/chrislloyd/received_events","type":"User","site_admin":false},"created_at":"2016-04-13T04:47:06Z","updated_at":"2016-04-13T04:47:06Z","body":"@psimyn that's what we're currently using. I thought it was initially less ideal as it couples our jest harness to our webpack config.\r\n\r\nHowever, thinking more about it, if the guard was inverted, it might actually be a decent solution as jest fundamentally can only mock JS.\r\n\r\n```\r\nif (!filename.match(/\\.jsx?$/)) {\r\n  return '';\r\n}\r\n```"}}