{"action":"created","issue":{"url":"https://api.github.com/repos/lelandrichardson/react-native-mock/issues/23","repository_url":"https://api.github.com/repos/lelandrichardson/react-native-mock","labels_url":"https://api.github.com/repos/lelandrichardson/react-native-mock/issues/23/labels{/name}","comments_url":"https://api.github.com/repos/lelandrichardson/react-native-mock/issues/23/comments","events_url":"https://api.github.com/repos/lelandrichardson/react-native-mock/issues/23/events","html_url":"https://github.com/lelandrichardson/react-native-mock/issues/23","id":140115209,"number":23,"title":"Issues with mocking interfering with 3rd-party node modules","user":{"login":"rlau1115","id":6392065,"avatar_url":"https://avatars.githubusercontent.com/u/6392065?v=3","gravatar_id":"","url":"https://api.github.com/users/rlau1115","html_url":"https://github.com/rlau1115","followers_url":"https://api.github.com/users/rlau1115/followers","following_url":"https://api.github.com/users/rlau1115/following{/other_user}","gists_url":"https://api.github.com/users/rlau1115/gists{/gist_id}","starred_url":"https://api.github.com/users/rlau1115/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rlau1115/subscriptions","organizations_url":"https://api.github.com/users/rlau1115/orgs","repos_url":"https://api.github.com/users/rlau1115/repos","events_url":"https://api.github.com/users/rlau1115/events{/privacy}","received_events_url":"https://api.github.com/users/rlau1115/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-03-11T07:58:01Z","updated_at":"2016-05-02T15:53:19Z","closed_at":null,"body":"I'm having some issues getting a basic test to compile. I'm fairly new to React Native / Mocha / Babel so any insight would be helpful.\r\n\r\nI followed your advice regarding forcing babel to compile node modules [here](https://github.com/facebook/react-native/issues/5392), with some modifications of my own due to some problematic modules. However, now the issue seems to be that there is a conflict between react-native-mock getting in the way of an external node module (\"react-native-router-flux\" in this case) from functioning properly.\r\n\r\nAny thoughts would be greatly appreciated!\r\n\r\n```\r\n/* .babelrc */\r\n\r\n{ \r\n  \"presets\": [\"stage-1\", \"react-native\"]\r\n}\r\n```\r\n```\r\n/* MyComponent.js */\r\n\r\n'use strict';\r\n\r\nvar React = require('react-native');\r\nvar {View, Text, StyleSheet, TouchableHighlight} = React;\r\nvar Button = require('react-native-button');\r\nvar Actions = require('react-native-router-flux').Actions;\r\n\r\nclass MyComponent extends React.Component {\r\n  render() {\r\n    return (\r\n      <View style={styles.container}>\r\n        <Text style={styles.baseText}>Test!</Text>\r\n        <Button onPress={()=>Actions.login({data:\"Custom data\", title:'Custom title' })}>Go to Login page</Button>\r\n        <Button onPress={Actions.signup}>Go to Register page</Button>\r\n      </View>\r\n    );\r\n  }\r\n}\r\n\r\nvar styles = StyleSheet.create({\r\n    container: {\r\n        flex: 1,\r\n        justifyContent: 'center',\r\n        alignItems: 'center',\r\n        backgroundColor: 'transparent',\r\n    },\r\n    baseText: {\r\n      fontFamily: 'Raleway-Regular'\r\n    }\r\n});\r\n\r\nmodule.exports = MyComponent;\r\n```\r\n\r\n```\r\n/* MyComponent_spec.js */\r\n\r\nimport React from 'react';\r\nimport { shallow } from 'enzyme';\r\nimport { View, Text, StyleSheet } from 'react-native';\r\n\r\nimport MyComponent from '../../../react/components/ecosystems/MyComponent';\r\n\r\ndescribe(\"<MyComponent/>\", () => {\r\n  it('should render', () => {\r\n    const wrapper = shallow(<MyComponent />);\r\n    expect(wrapper).to.be.ok;\r\n  });\r\n});\r\n```\r\n\r\n```\r\n/* package.json */\r\n\r\n{\r\n  \"name\": \"Test\",\r\n  \"version\": \"0.0.1\",\r\n  \"private\": true,\r\n  \"scripts\": {\r\n    \"start\": \"node node_modules/react-native/local-cli/cli.js start\",\r\n    \"test\": \"mocha --require ./test/setup.js --compilers js:babel-core/register 'test/**/*.@(js|jsx)'\"\r\n  },\r\n  \"dependencies\": {\r\n    \"immutable\": \"^3.7.6\",\r\n    \"react-native\": \"^0.21.0\",\r\n    \"react-native-button\": \"^1.4.2\",\r\n    \"react-native-router-flux\": \"^2.3.12\",\r\n    \"react-redux\": \"^4.4.0\",\r\n    \"redux\": \"^3.3.1\"\r\n  },\r\n  \"devDependencies\": {\r\n    \"babel-cli\": \"^6.6.5\",\r\n    \"babel-core\": \"^6.7.2\",\r\n    \"babel-plugin-transform-es2015-modules-commonjs\": \"^6.7.0\",\r\n    \"babel-polyfill\": \"^6.7.2\",\r\n    \"babel-preset-es2015\": \"^6.6.0\",\r\n    \"babel-preset-react\": \"^6.5.0\",\r\n    \"babel-preset-react-native\": \"^1.5.2\",\r\n    \"babel-preset-stage-1\": \"^6.5.0\",\r\n    \"chai\": \"^3.5.0\",\r\n    \"chai-immutable\": \"^1.5.3\",\r\n    \"enzyme\": \"^2.1.0\",\r\n    \"mocha\": \"^2.4.5\",\r\n    \"react\": \"^0.14.7\",\r\n    \"react-addons-test-utils\": \"^0.14.7\",\r\n    \"react-dom\": \"^0.14.7\",\r\n    \"react-native-mock\": \"0.0.6\",\r\n    \"redux-devtools\": \"^3.1.1\",\r\n    \"sinon\": \"^1.17.3\",\r\n    \"slash\": \"^1.0.0\"\r\n  }\r\n}\r\n```\r\n\r\n```\r\n/* ./test/setup.js */\r\n\r\n\"use strict\";\r\nrequire(\"babel-polyfill\");\r\n\r\nvar fs = require('fs');\r\nvar path = require('path');\r\n\r\nfunction getBabelRC() {\r\n  var rcpath = path.join(__dirname, '..', '.babelrc');\r\n  var source = fs.readFileSync(rcpath).toString();\r\n  return JSON.parse(source);\r\n}\r\n\r\nvar config = getBabelRC();\r\n\r\nconfig.ignore = function(filename) {\r\n  if (!(/\\/node_modules\\//).test(filename)) {\r\n\r\n    // if not in node_modules, we want to compile it\r\n    return false; \r\n\r\n  } else if ((/\\/node_modules\\/react-native\\//).test(filename)) {\r\n    \r\n    // it's RN source code, so we want to compile it\r\n    return false;\r\n\r\n  } else {\r\n    // it's in node modules and NOT RN source code\r\n    var modulesToCompileArray = [\r\n      \"react-native-button\",\r\n      \"react-native-router-flux\",\r\n      \"react-native-tabs\",\r\n      \"exponent\",\r\n      \"react-native-clone-referenced-element\",\r\n    ];\r\n\r\n    for (var i = 0; i < modulesToCompileArray.length; i++) {\r\n      if (filename.includes(modulesToCompileArray[i])) {\r\n        return false;\r\n      }\r\n    }\r\n\r\n    return true;\r\n  }\r\n}\r\n\r\nrequire(\"babel-core/register\")(config);\r\n\r\nglobal.__DEV__ = true;\r\n\r\nvar chai = require('chai');\r\nvar chaiImmutable = require('chai-immutable');\r\n\r\nglobal.expect = chai.expect;\r\nchai.use(chaiImmutable);\r\n\r\nrequire(\"react-native-mock/mock\");\r\n```\r\n\r\nThis is the error that I get when running the tests.\r\n\r\n```\r\nnpm run test\r\n\r\n> TestApp@0.0.1 test .../src...\r\n> mocha --require ./test/setup.js --compilers js:babel-core/register 'test/**/*.@(js|jsx)'\r\n.../src.../node_modules/@exponent/react-native-navigator/ExSceneConfigs.js:193\r\nFade:_reactNative.Navigator.SceneConfigs.FadeAndroid,\r\n                                        ^\r\n\r\nTypeError: Cannot read property 'FadeAndroid' of undefined\r\n    at Object.<anonymous> (ExSceneConfigs.js:193:9)\r\n    at Module._compile (module.js:413:34)\r\n    at loader (.../src.../node_modules/babel-core/node_modules/babel-register/lib/node.js:126:5)\r\n    at Object.require.extensions.(anonymous function) [as .js] (.../src.../node_modules/babel-core/node_modules/babel-register/lib/node.js:136:7)\r\n    at Module.load (module.js:357:32)\r\n    at Function.Module._load (module.js:314:12)\r\n    at Module.require (module.js:367:17)\r\n    at require (internal/module.js:16:19)\r\n    at Object.<anonymous> (ExRouteRenderer.js:16:1)\r\n    at Module._compile (module.js:413:34)\r\n    at loader (.../src.../node_modules/babel-core/node_modules/babel-register/lib/node.js:126:5)\r\n    at Object.require.extensions.(anonymous function) [as .js] (.../src.../node_modules/babel-core/node_modules/babel-register/lib/node.js:136:7)\r\n    at Module.load (module.js:357:32)\r\n    at Function.Module._load (module.js:314:12)\r\n    at Module.require (module.js:367:17)\r\n    at require (internal/module.js:16:19)\r\n    at Object.<anonymous> (ExNavigator.js:16:1)\r\n    at Module._compile (module.js:413:34)\r\n    at loader (.../src.../node_modules/babel-core/node_modules/babel-register/lib/node.js:126:5)\r\n    at Object.require.extensions.(anonymous function) [as .js] (.../src.../node_modules/babel-core/node_modules/babel-register/lib/node.js:136:7)\r\n    at Module.load (module.js:357:32)\r\n    at Function.Module._load (module.js:314:12)\r\n    at Module.require (module.js:367:17)\r\n    at require (internal/module.js:16:19)\r\n    at Object.<anonymous> (ExRouter.js:5:1)\r\n    at Module._compile (module.js:413:34)\r\n    at loader (.../src.../node_modules/babel-core/node_modules/babel-register/lib/node.js:126:5)\r\n    at Object.require.extensions.(anonymous function) [as .js] (.../src.../node_modules/babel-core/node_modules/babel-register/lib/node.js:136:7)\r\n    at Module.load (module.js:357:32)\r\n    at Function.Module._load (module.js:314:12)\r\n    at Module.require (module.js:367:17)\r\n    at require (internal/module.js:16:19)\r\n    at Object.<anonymous> (Router.js:12:1)\r\n    at Module._compile (module.js:413:34)\r\n    at loader (.../src.../node_modules/babel-core/node_modules/babel-register/lib/node.js:126:5)\r\n    at Object.require.extensions.(anonymous function) [as .js] (.../src.../node_modules/babel-core/node_modules/babel-register/lib/node.js:136:7)\r\n    at Module.load (module.js:357:32)\r\n    at Function.Module._load (module.js:314:12)\r\n    at Module.require (module.js:367:17)\r\n    at require (internal/module.js:16:19)\r\n    at Object.<anonymous> (index.js:4:1)\r\n    at Module._compile (module.js:413:34)\r\n    at loader (.../src.../node_modules/babel-core/node_modules/babel-register/lib/node.js:126:5)\r\n    at Object.require.extensions.(anonymous function) [as .js] (.../src.../node_modules/babel-core/node_modules/babel-register/lib/node.js:136:7)\r\n    at Module.load (module.js:357:32)\r\n    at Function.Module._load (module.js:314:12)\r\n    at Module.require (module.js:367:17)\r\n    at require (internal/module.js:16:19)\r\n    at Object.<anonymous> (Welcome.js:6:15)\r\n    at Module._compile (module.js:413:34)\r\n    at loader (.../src.../node_modules/babel-core/node_modules/babel-register/lib/node.js:126:5)\r\n    at Object.require.extensions.(anonymous function) [as .js] (.../src.../node_modules/babel-core/node_modules/babel-register/lib/node.js:136:7)\r\n    at Module.load (module.js:357:32)\r\n    at Function.Module._load (module.js:314:12)\r\n    at Module.require (module.js:367:17)\r\n    at require (internal/module.js:16:19)\r\n    at Object.<anonymous> (Welcome_spec.js:5:1)\r\n    at Module._compile (module.js:413:34)\r\n    at loader (.../src.../node_modules/babel-core/node_modules/babel-register/lib/node.js:126:5)\r\n    at Object.require.extensions.(anonymous function) [as .js] (.../src.../node_modules/babel-core/node_modules/babel-register/lib/node.js:136:7)\r\n    at Module.load (module.js:357:32)\r\n    at Function.Module._load (module.js:314:12)\r\n    at Module.require (module.js:367:17)\r\n    at require (internal/module.js:16:19)\r\n    at .../src.../node_modules/mocha/lib/mocha.js:219:27\r\n    at Array.forEach (native)\r\n    at Mocha.loadFiles (.../src.../node_modules/mocha/lib/mocha.js:216:14)\r\n    at Mocha.run (.../src.../node_modules/mocha/lib/mocha.js:468:10)\r\n    at Object.<anonymous> (.../src.../node_modules/mocha/bin/_mocha:403:18)\r\n    at Module._compile (module.js:413:34)\r\n    at Object.Module._extensions..js (module.js:422:10)\r\n    at Module.load (module.js:357:32)\r\n    at Function.Module._load (module.js:314:12)\r\n    at Function.Module.runMain (module.js:447:10)\r\n    at startup (node.js:141:18)\r\n    at node.js:933:3\r\n\r\nnpm ERR! Darwin 15.3.0\r\nnpm ERR! argv \"/Users/noobs/.nvm/versions/node/v5.7.1/bin/node\" \"/Users/noobs/.nvm/versions/node/v5.7.1/bin/npm\" \"run\" \"test\"\r\nnpm ERR! node v5.7.1\r\nnpm ERR! npm  v3.6.0\r\nnpm ERR! code ELIFECYCLE\r\nnpm ERR! TestApp@0.0.1 test: `mocha --require ./test/setup.js --compilers js:babel-core/register 'test/**/*.@(js|jsx)'`\r\nnpm ERR! Exit status 1\r\nnpm ERR! \r\nnpm ERR! Failed at the TestApp@0.0.1 test script 'mocha --require ./test/setup.js --compilers js:babel-core/register 'test/**/*.@(js|jsx)''.\r\nnpm ERR! Make sure you have the latest version of node.js and npm installed.\r\nnpm ERR! If you do, this is most likely a problem with the TestApp package,\r\nnpm ERR! not with npm itself.\r\nnpm ERR! Tell the author that this fails on your system:\r\nnpm ERR!     mocha --require ./test/setup.js --compilers js:babel-core/register 'test/**/*.@(js|jsx)'\r\nnpm ERR! You can get information on how to open an issue for this project with:\r\nnpm ERR!     npm bugs TestApp\r\nnpm ERR! Or if that isn't available, you can get their info via:\r\nnpm ERR!     npm owner ls TestApp\r\nnpm ERR! There is likely additional logging output above.\r\n\r\nnpm ERR! Please include the following file with any support request:\r\nnpm ERR!     .../src.../npm-debug.log\r\n```"},"comment":{"url":"https://api.github.com/repos/lelandrichardson/react-native-mock/issues/comments/216274884","html_url":"https://github.com/lelandrichardson/react-native-mock/issues/23#issuecomment-216274884","issue_url":"https://api.github.com/repos/lelandrichardson/react-native-mock/issues/23","id":216274884,"user":{"login":"slamus","id":2813579,"avatar_url":"https://avatars.githubusercontent.com/u/2813579?v=3","gravatar_id":"","url":"https://api.github.com/users/slamus","html_url":"https://github.com/slamus","followers_url":"https://api.github.com/users/slamus/followers","following_url":"https://api.github.com/users/slamus/following{/other_user}","gists_url":"https://api.github.com/users/slamus/gists{/gist_id}","starred_url":"https://api.github.com/users/slamus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slamus/subscriptions","organizations_url":"https://api.github.com/users/slamus/orgs","repos_url":"https://api.github.com/users/slamus/repos","events_url":"https://api.github.com/users/slamus/events{/privacy}","received_events_url":"https://api.github.com/users/slamus/received_events","type":"User","site_admin":false},"created_at":"2016-05-02T15:53:19Z","updated_at":"2016-05-02T15:53:19Z","body":"@rlau1115 @vysakh0 I feel that's it's most of RN testers destiny... :("}}