{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/react-native/issues/700","labels_url":"https://api.github.com/repos/facebook/react-native/issues/700/labels{/name}","comments_url":"https://api.github.com/repos/facebook/react-native/issues/700/comments","events_url":"https://api.github.com/repos/facebook/react-native/issues/700/events","html_url":"https://github.com/facebook/react-native/issues/700","id":66593236,"number":700,"title":"require('react-native') and jest test fails","user":{"login":"rogergl","id":98088,"avatar_url":"https://avatars.githubusercontent.com/u/98088?v=3","gravatar_id":"","url":"https://api.github.com/users/rogergl","html_url":"https://github.com/rogergl","followers_url":"https://api.github.com/users/rogergl/followers","following_url":"https://api.github.com/users/rogergl/following{/other_user}","gists_url":"https://api.github.com/users/rogergl/gists{/gist_id}","starred_url":"https://api.github.com/users/rogergl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rogergl/subscriptions","organizations_url":"https://api.github.com/users/rogergl/orgs","repos_url":"https://api.github.com/users/rogergl/repos","events_url":"https://api.github.com/users/rogergl/events{/privacy}","received_events_url":"https://api.github.com/users/rogergl/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-04-06T12:20:21Z","updated_at":"2015-05-26T05:52:41Z","closed_at":null,"body":"I have the following simple Module\r\n\r\n```javascript\r\n/**\r\n * @providesModule DropBox\r\n * @flow\r\n */\r\n'use strict';\r\n\r\nvar React = require('react-native');\r\nvar {\r\n   NativeModules,\r\n    } = React;\r\n\r\nvar _ = require('underscore')._;\r\n\r\nclass DropBox {\r\n\r\n    constructor() {\r\n        this.nativeModule = NativeModule.DropBox;\r\n    }\r\n\r\n    loadFiles() {\r\n        return new Promise((resolve, reject) => {\r\n            this.nativeModule.load((error, names, contents) => {\r\n                if (error) {\r\n                    reject(error);\r\n                } else {\r\n                    var parsedContent = contents.map((c) => {\r\n                        return JSON.parse(c);\r\n                    });\r\n                    resolve(_.zip(names, parsedContent));\r\n                }\r\n            });\r\n        })\r\n    }\r\n}\r\n\r\nmodule.exports = DropBox;\r\n```\r\nand the following test:\r\n\r\n```javascript\r\njest.dontMock('../js/model/DropBox');\r\n\r\ndescribe('loadFiles', function() {\r\n it('adds 1 + 2 to equal 3', function() {\r\n   var DropBox = require('../js/model/DropBox');\r\n   expect(1 + 21).toBe(3);\r\n });\r\n\r\n});\r\n```\r\nI know that the test is nonsense, but I just want to make sure that my setup works. Running npm test gives:\r\n  - TypeError: /Users/roger/Documents/AwesomeProject/js/model/DropBox.js: /Users/roger/Documents/AwesomeProject/node_modules/react-native/Libraries/react-native/react-native.js: /Users/roger/Documents/AwesomeProject/node_modules/react-tools/src/browser/ui/React.js: /Users/roger/Documents/AwesomeProject/node_modules/react-tools/src/modern/class/ReactComponent.js: /Users/roger/Documents/AwesomeProject/node_modules/react-tools/src/core/ReactUpdateQueue.js: /Users/roger/Documents/AwesomeProject/node_modules/react-tools/src/core/ReactUpdates.js: undefined is not a function\r\n        at /Users/roger/Documents/AwesomeProject/node_modules/react-tools/src/core/ReactUpdates.js:26:39\r\n        at /Users/roger/Documents/AwesomeProject/node_modules/react-tools/src/core/ReactUpdateQueue.js:18:20\r\n        at /Users/roger/Documents/AwesomeProject/node_modules/react-tools/src/modern/class/ReactComponent.js:14:24\r\n        at /Users/roger/Documents/AwesomeProject/node_modules/react-tools/src/browser/ui/React.js:18:22\r\n        at /Users/roger/Documents/AwesomeProject/node_modules/react-native/Libraries/react-native/react-native.js:20:47"},"comment":{"url":"https://api.github.com/repos/facebook/react-native/issues/comments/105406099","html_url":"https://github.com/facebook/react-native/issues/700#issuecomment-105406099","issue_url":"https://api.github.com/repos/facebook/react-native/issues/700","id":105406099,"user":{"login":"amasad","id":587518,"avatar_url":"https://avatars.githubusercontent.com/u/587518?v=3","gravatar_id":"","url":"https://api.github.com/users/amasad","html_url":"https://github.com/amasad","followers_url":"https://api.github.com/users/amasad/followers","following_url":"https://api.github.com/users/amasad/following{/other_user}","gists_url":"https://api.github.com/users/amasad/gists{/gist_id}","starred_url":"https://api.github.com/users/amasad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amasad/subscriptions","organizations_url":"https://api.github.com/users/amasad/orgs","repos_url":"https://api.github.com/users/amasad/repos","events_url":"https://api.github.com/users/amasad/events{/privacy}","received_events_url":"https://api.github.com/users/amasad/received_events","type":"User","site_admin":false},"created_at":"2015-05-26T05:52:41Z","updated_at":"2015-05-26T05:52:41Z","body":"The main reason for this issue is that we currently ship React in source form (`react-tools`) inside `react-native`. That means that it's written in ES6 and it depends on globals like `__DEV__`, which your jest setup should support that. We have plans to start shipping react from npm, (I think with React v0.14). @zpao can you confirm this?\r\n\r\nIn the mean time here is what you can do: adapt the [`jestSupport` directory](https://github.com/facebook/react-native/tree/master/jestSupport) and the jest config in the [package.json](https://github.com/facebook/react-native/blob/master/package.json#L9-L22) to be used with your project."}}