{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/jest/issues/216","labels_url":"https://api.github.com/repos/facebook/jest/issues/216/labels{/name}","comments_url":"https://api.github.com/repos/facebook/jest/issues/216/comments","events_url":"https://api.github.com/repos/facebook/jest/issues/216/events","html_url":"https://github.com/facebook/jest/issues/216","id":54576638,"number":216,"title":"unable to require('when') (cujojs/when) in test","user":{"login":"honzatrtik","id":1225333,"avatar_url":"https://avatars.githubusercontent.com/u/1225333?v=3","gravatar_id":"","url":"https://api.github.com/users/honzatrtik","html_url":"https://github.com/honzatrtik","followers_url":"https://api.github.com/users/honzatrtik/followers","following_url":"https://api.github.com/users/honzatrtik/following{/other_user}","gists_url":"https://api.github.com/users/honzatrtik/gists{/gist_id}","starred_url":"https://api.github.com/users/honzatrtik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/honzatrtik/subscriptions","organizations_url":"https://api.github.com/users/honzatrtik/orgs","repos_url":"https://api.github.com/users/honzatrtik/repos","events_url":"https://api.github.com/users/honzatrtik/events{/privacy}","received_events_url":"https://api.github.com/users/honzatrtik/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-01-16T13:45:11Z","updated_at":"2015-02-14T12:49:53Z","closed_at":null,"body":"Hello!\r\nMy test file is as simple as\r\n\r\n```javascript\r\n\r\nvar when = require('when');\r\n\r\n```\r\n\r\n\r\nbut still throws error even if i disable mocking using jest.dontMock('when')\r\n\r\n```\r\n/Users/honzatrtik/Workspace/bandzone3/src/www/js2/node_modules/when/when.js: Cannot read property 'resolve' of undefined\r\n    at /Users/honzatrtik/Workspace/bandzone3/src/www/js2/node_modules/when/when.js:35:28\r\n    at /Users/honzatrtik/Workspace/bandzone3/src/www/js2/node_modules/when/when.js:229:96\r\n    at /Users/honzatrtik/Workspace/bandzone3/src/www/js2/node_modules/when/when.js:11:1\r\n    at /Users/honzatrtik/Workspace/bandzone3/src/www/js2/node_modules/when/when.js:229:3\r\n    at Object.runContentWithLocalBindings (/Users/honzatrtik/Workspace/bandzone3/src/www/js2/node_modules/jest-cli/src/lib/utils.js:357:17)\r\n    at Loader._execModule (/Users/honzatrtik/Workspace/bandzone3/src/www/js2/node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:245:9)\r\n    at Loader.requireModule (/Users/honzatrtik/Workspace/bandzone3/src/www/js2/node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:900:12)\r\n    at Loader.requireModuleOrMock (/Users/honzatrtik/Workspace/bandzone3/src/www/js2/node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:921:17)\r\n    at /Users/honzatrtik/Workspace/bandzone3/src/www/js2/src/components/gig-list/__tests__/filter-genre-group.js:13:12\r\n    at Object.runContentWithLocalBindings (/Users/honzatrtik/Workspace/bandzone3/src/www/js2/node_modules/jest-cli/src/lib/utils.js:357:17)\r\n    at Loader._execModule (/Users/honzatrtik/Workspace/bandzone3/src/www/js2/node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:245:9)\r\n    at Loader.requireModule (/Users/honzatrtik/Workspace/bandzone3/src/www/js2/node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:900:12)\r\n    at jasmineTestRunner (/Users/honzatrtik/Workspace/bandzone3/src/www/js2/node_modules/jest-cli/src/jasmineTestRunner/jasmineTestRunner.js:239:16)\r\n    at /Users/honzatrtik/Workspace/bandzone3/src/www/js2/node_modules/jest-cli/src/TestRunner.js:371:12\r\n    at _fulfilled (/Users/honzatrtik/Workspace/bandzone3/src/www/js2/node_modules/jest-cli/node_modules/q/q.js:798:54)\r\n    at self.promiseDispatch.done (/Users/honzatrtik/Workspace/bandzone3/src/www/js2/node_modules/jest-cli/node_modules/q/q.js:827:30)\r\n    at Promise.promise.promiseDispatch (/Users/honzatrtik/Workspace/bandzone3/src/www/js2/node_modules/jest-cli/node_modules/q/q.js:760:13)\r\n    at /Users/honzatrtik/Workspace/bandzone3/src/www/js2/node_modules/jest-cli/node_modules/q/q.js:574:44\r\n    at flush (/Users/honzatrtik/Workspace/bandzone3/src/www/js2/node_modules/jest-cli/node_modules/q/q.js:108:17)\r\n    at /Users/honzatrtik/Workspace/bandzone3/src/www/js2/node_modules/jest-cli/src/lib/FakeTimers.js:259:7\r\n    at process._tickCallback (node.js:419:13)\r\n```\r\n\r\nIs there any workaround?\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/facebook/jest/issues/comments/74373806","html_url":"https://github.com/facebook/jest/issues/216#issuecomment-74373806","issue_url":"https://api.github.com/repos/facebook/jest/issues/216","id":74373806,"user":{"login":"benzen","id":139909,"avatar_url":"https://avatars.githubusercontent.com/u/139909?v=3","gravatar_id":"","url":"https://api.github.com/users/benzen","html_url":"https://github.com/benzen","followers_url":"https://api.github.com/users/benzen/followers","following_url":"https://api.github.com/users/benzen/following{/other_user}","gists_url":"https://api.github.com/users/benzen/gists{/gist_id}","starred_url":"https://api.github.com/users/benzen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benzen/subscriptions","organizations_url":"https://api.github.com/users/benzen/orgs","repos_url":"https://api.github.com/users/benzen/repos","events_url":"https://api.github.com/users/benzen/events{/privacy}","received_events_url":"https://api.github.com/users/benzen/received_events","type":"User","site_admin":false},"created_at":"2015-02-14T12:49:53Z","updated_at":"2015-02-14T12:49:53Z","body":"I get into the same trap, thanks to @wwalser it's was easy to get out.\r\nStill, it seems to me that even if the module that my moduleUnderTest depends are mocked out.\r\nThe module they depend on are still required (i mean node's required) and then mocked out.\r\n\r\nMaybe it will be clearer as a draw:\r\nA -> B -> C\r\n\r\nThe module i'm testing is A. When testing it, i'm expecting B to be mocked and not to require C for real.\r\nBut it seams to me that what is happening is this:\r\n\r\nA -> mock(B) -> B -> mock(C) -> C\r\n\r\nIs this because of the automatic construction of the mock ?\r\n"}}