{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/jest/issues/602","labels_url":"https://api.github.com/repos/facebook/jest/issues/602/labels{/name}","comments_url":"https://api.github.com/repos/facebook/jest/issues/602/comments","events_url":"https://api.github.com/repos/facebook/jest/issues/602/events","html_url":"https://github.com/facebook/jest/issues/602","id":116192930,"number":602,"title":"`unmockedModulePathPatterns` not matching module paths properly with npm 3","user":{"login":"hgezim","id":124675,"avatar_url":"https://avatars.githubusercontent.com/u/124675?v=3","gravatar_id":"","url":"https://api.github.com/users/hgezim","html_url":"https://github.com/hgezim","followers_url":"https://api.github.com/users/hgezim/followers","following_url":"https://api.github.com/users/hgezim/following{/other_user}","gists_url":"https://api.github.com/users/hgezim/gists{/gist_id}","starred_url":"https://api.github.com/users/hgezim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hgezim/subscriptions","organizations_url":"https://api.github.com/users/hgezim/orgs","repos_url":"https://api.github.com/users/hgezim/repos","events_url":"https://api.github.com/users/hgezim/events{/privacy}","received_events_url":"https://api.github.com/users/hgezim/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-11-10T20:18:10Z","updated_at":"2015-11-10T23:12:08Z","closed_at":"2015-11-10T23:08:42Z","body":"Here's a part of `jest` key in my `package.json`:\r\n\r\n```\r\n\"jest\": {\r\n    \"scriptPreprocessor\": \"<rootDir>/node_modules/babel-jest\",\r\n    \"unmockedModulePathPatterns\": [\r\n      \"/history\",\r\n      \"/react\",\r\n      \"/react-bootstrap\",\r\n      ...\r\n```\r\n\r\nI'm on `node 5.0.0`. With `npm 2.14.10` after deleting `node_modules` and doing a fresh `npm install`, my jest test passes:\r\n\r\n```\r\n$ rm -rf node_modules \r\n$ npm install\r\n$ npm --version\r\n2.14.10\r\n$ npm test -- src/javascript/components/FilePicker/__tests__/FilePicker-test.js\r\n...\r\n7 tests passed (7 total in 1 test suite, run time 3.705s)\r\n```\r\n\r\nAs, there's an issue with npm 3.x as I'll demonstrate, I added a couple `console.log` lines in `HasteModuleLoader.js` in `_shouldMock` method right before the `for` loop that checks the regular expressions for files to ignore for mocking.\r\n\r\nFor `npm 2.14.10`, this is the  relevant output:\r\n\r\n```\r\nmodulePath: /Users/myuname/projects/myproj/frontend/node_modules/react-bootstrap/node_modules/uncontrollable/index.js\r\nrealPath: /Users/myuname/projects/myproj/frontend/node_modules/react-bootstrap/node_modules/uncontrollable/index.js\r\nmodulePath: /Users/myuname/projects/myproj/frontend/node_modules/react-bootstrap/node_modules/uncontrollable/createUncontrollable.js\r\nrealPath: /Users/myuname/projects/myproj/frontend/node_modules/react-bootstrap/node_modules/uncontrollable/createUncontrollable.js\r\nmodulePath: /Users/myuname/projects/myproj/frontend/node_modules/react-bootstrap/node_modules/uncontrollable/utils.js\r\nrealPath: /Users/myuname/projects/myproj/frontend/node_modules/react-bootstrap/node_modules/uncontrollable/utils.js\r\n```\r\n\r\nNow, I upgrade to `npm 3.3.12` and do a fresh `npm install`:\r\n\r\n```\r\n$ sudo npm install npm -g\r\n$ npm --version\r\n3.3.12\r\n$ rm -rf node_modules && npm install\r\n...\r\n```\r\n\r\nI now run the test exactly as before and get an error:\r\n\r\n```\r\n$ npm test -- src/javascript/components/FilePicker/__tests__/FilePicker-test.js\r\n...\r\n FAIL  src/javascript/components/FilePicker/__tests__/FilePicker-test.js \r\n● Runtime Error\r\nTypeError: /Users/myuname/projects/myproj/frontend/src/javascript/components/FilePicker/__tests__/FilePicker-test.js: /Users/myuname/projects/myproj/frontend/src/javascript/components/FilePicker/FilePicker.jsx: /Users/myuname/projects/myproj/frontend/src/javascript/components/FilePicker/Breadcrumbs.jsx: /Users/myuname/projects/myproj/frontend/node_modules/react-bootstrap/lib/index.js: /Users/myuname/projects/myproj/frontend/node_modules/react-bootstrap/lib/Dropdown.js: _uncontrollable2.default is not a function\r\nnpm ERR! Test failed.  See above for more details.\r\n```\r\n\r\nLooking at the output of my `console.log`s (which I had to add again since I did a fresh `npm install`), I noticed that the module paths are totally different:\r\n\r\n```\r\nmodulePath: /Users/myuname/projects/myproj/frontend/node_modules/uncontrollable/index.js\r\nrealPath: /Users/myuname/projects/myproj/frontend/node_modules/uncontrollable/index.js\r\nmodulePath: /Users/myuname/projects/myproj/frontend/node_modules/uncontrollable/createUncontrollable.js\r\nrealPath: /Users/myuname/projects/myproj/frontend/node_modules/uncontrollable/createUncontrollable.js\r\nmodulePath: /Users/myuname/projects/myproj/frontend/node_modules/uncontrollable/utils.js\r\nrealPath: /Users/myuname/projects/myproj/frontend/node_modules/uncontrollable/utils.js\r\n```\r\n\r\nMy `/react-bootstrap` in `unmockedModulePathPatterns` no longer matches thess paths.\r\n\r\nAlso, `uncontrollable` is still only used by `react-bootstrap`:\r\n\r\n```\r\n$ npm list uncontrollable\r\nmyproj-frontend@0.0.1 /Users/myuname/projects/myproj/frontend\r\n└─┬ react-bootstrap@0.27.3\r\n  └── uncontrollable@3.1.3 \r\n```"},"comment":{"url":"https://api.github.com/repos/facebook/jest/issues/comments/155597827","html_url":"https://github.com/facebook/jest/issues/602#issuecomment-155597827","issue_url":"https://api.github.com/repos/facebook/jest/issues/602","id":155597827,"user":{"login":"hgezim","id":124675,"avatar_url":"https://avatars.githubusercontent.com/u/124675?v=3","gravatar_id":"","url":"https://api.github.com/users/hgezim","html_url":"https://github.com/hgezim","followers_url":"https://api.github.com/users/hgezim/followers","following_url":"https://api.github.com/users/hgezim/following{/other_user}","gists_url":"https://api.github.com/users/hgezim/gists{/gist_id}","starred_url":"https://api.github.com/users/hgezim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hgezim/subscriptions","organizations_url":"https://api.github.com/users/hgezim/orgs","repos_url":"https://api.github.com/users/hgezim/repos","events_url":"https://api.github.com/users/hgezim/events{/privacy}","received_events_url":"https://api.github.com/users/hgezim/received_events","type":"User","site_admin":false},"created_at":"2015-11-10T23:12:08Z","updated_at":"2015-11-10T23:12:08Z","body":"Yup, that should do it for now. My apologies. I didn't see #554."}}