{"action":"created","issue":{"url":"https://api.github.com/repos/bartonhammond/snowflake/issues/48","labels_url":"https://api.github.com/repos/bartonhammond/snowflake/issues/48/labels{/name}","comments_url":"https://api.github.com/repos/bartonhammond/snowflake/issues/48/comments","events_url":"https://api.github.com/repos/bartonhammond/snowflake/issues/48/events","html_url":"https://github.com/bartonhammond/snowflake/issues/48","id":129416109,"number":48,"title":"[QUESTION] Can't properly setup async actions test on my app","user":{"login":"chukcha-wtf","id":1046073,"avatar_url":"https://avatars.githubusercontent.com/u/1046073?v=3","gravatar_id":"","url":"https://api.github.com/users/chukcha-wtf","html_url":"https://github.com/chukcha-wtf","followers_url":"https://api.github.com/users/chukcha-wtf/followers","following_url":"https://api.github.com/users/chukcha-wtf/following{/other_user}","gists_url":"https://api.github.com/users/chukcha-wtf/gists{/gist_id}","starred_url":"https://api.github.com/users/chukcha-wtf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chukcha-wtf/subscriptions","organizations_url":"https://api.github.com/users/chukcha-wtf/orgs","repos_url":"https://api.github.com/users/chukcha-wtf/repos","events_url":"https://api.github.com/users/chukcha-wtf/events{/privacy}","received_events_url":"https://api.github.com/users/chukcha-wtf/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":15,"created_at":"2016-01-28T10:51:34Z","updated_at":"2016-01-29T00:26:49Z","closed_at":null,"body":"Hi, I was looking at your project to get basic ideas for testing my RN app with `redux`, `redux-thunk` and a set of async actions. Thanks for your great work I've been able to successfully test basic actions and components rendering, but can't make it work with promises. \r\n\r\nMy app is RN 0.18 application with the following `package.json` config:\r\n```json\r\n{\r\n  \"name\": \"myApp\",\r\n  \"version\": \"0.0.1\",\r\n  \"private\": true,\r\n  \"scripts\": {\r\n    \"start\": \"react-native start\",\r\n    \"test\": \"rm -rf ./node_modules/jest-cli/.haste_cache && jest --verbose\",\r\n    \"test:watch\": \"npm run test -- --watch\"\r\n  },\r\n  \"jest\": {\r\n    \"scriptPreprocessor\": \"jestSupport/scriptPreprocess.js\",\r\n    \"setupEnvScriptFile\": \"node_modules/react-native/jestSupport/env.js\",\r\n    \"testPathIgnorePatterns\": [\r\n      \"/node_modules/\",\r\n      \"packager/react-packager/src/Activity/\"\r\n    ],\r\n    \"testFileExtensions\": [\r\n      \"js\"\r\n    ],\r\n    \"moduleFileExtensions\": [\r\n      \"js\"\r\n    ],\r\n    \"unmockedModulePathPatterns\": [\r\n      \"react\",\r\n      \"react-addons-test-utils\",\r\n      \"promise\",\r\n      \"source-map\",\r\n      \"key-mirror\",\r\n      \"immutable\",\r\n      \"fetch\",\r\n      \"redux\",\r\n      \"redux-thunk\",\r\n      \"fbjs\"\r\n    ]\r\n  },\r\n  \"dependencies\": {\r\n    \"lodash\": \"^3.10.1\",\r\n    \"react-native\": \"0.18.0\",\r\n    \"react-native-android-statusbar\": \"^0.1.2\",\r\n    \"react-native-fs\": \"1.1.0\",\r\n    \"react-native-sqlite-storage\": \"^2.1.1\",\r\n    \"react-native-vector-icons\": \"^1.0.0\",\r\n    \"react-redux\": \"3.1.2\",\r\n    \"react-timer-mixin\": \"^0.13.3\",\r\n    \"redux\": \"^3.0.5\",\r\n    \"redux-thunk\": \"^1.0.2\"\r\n  },\r\n  \"devDependencies\": {\r\n    \"art\": \"^0.10.1\",\r\n    \"babel-core\": \"^6.4.5\",\r\n    \"babel-jest\": \"^6.0.1\",\r\n    \"d3\": \"^3.5.12\",\r\n    \"jest-cli\": \"^0.8.2\",\r\n    \"moment\": \"^2.10.6\",\r\n    \"react\": \"^0.14.3\",\r\n    \"react-addons-test-utils\": \"^0.14.3\"\r\n  }\r\n}\r\n```\r\n\r\nMy tests are placed at the top directory like so:\r\n\r\n```\r\n. myApp\r\n|-- index.android.js\r\n|-- index.ios.js\r\n|-- app/\r\n|-- android/\r\n|-- ios/\r\n|-- __tests__\r\n|  |-- actions\r\n|    └-- appState-test.js\r\n|-- mocks\r\n|  └-- Store.js\r\n└-- package.json\r\n```\r\n\r\n`Store.js` file looks exactly like the one you've got [here](https://github.com/bartonhammond/snowflake/blob/master/src%2Freducers%2Fmocks%2FStore.js) and my `appState-test.js` file looks like:\r\n\r\n```js\r\n'use strict';\r\n\r\njest.autoMockOff();\r\n\r\nconst mockStore = require('../../exampleStore/snowflakeStore').default;\r\nconst actions = require('../../app/actions/appState');\r\n\r\nimport * as types from '../../app/constants/actionTypes';\r\n\r\ndescribe('appStateSnowflake', () => {\r\n  pit('should fetchSMTH', () => {    \r\n    const expectedActions = [\r\n      {type: types.START_FETCH_SMTH},\r\n      {type: types.END_FETCH_SMTH}\r\n    ];\r\n\r\n    const store = mockStore({}, expectedActions);\r\n    return store.dispatch(actions.fetchSMTH());\r\n  });\r\n});\r\n```\r\n\r\nWhere `actions/appState.js` looks following:\r\n\r\n```js\r\nimport * as types from '../constants/actionTypes';\r\n\r\nfunction startFetchSMTH() {\r\n  console.log('startFetchSMTH')\r\n  return { type: types.START_FETCH_SMTH }\r\n}\r\n\r\nfunction endFetchSMTH() {\r\n  console.log('endFetchSMTH')\r\n  return { type: types.END_FETCH_SMTH }\r\n}\r\n\r\nfunction doSomething() {\r\n  console.log('Doing smth')\r\n  return Promise.resolve();\r\n}\r\n\r\nexport function fetchSMTH() {\r\n  console.log('fetchSMTH')\r\n\r\n  return (dispatch) => {\r\n    dispatch(startFetchSMTH());\r\n\r\n    return doSomething().then(() => {\r\n      console.log('Im here HELP ME!!!')\r\n      dispatch(endFetchSMTH())\r\n    });\r\n  }\r\n}\r\n```\r\n\r\nHowever when I'm running my tests, only `START_FETCH_SMTH` has been dispatched and then I'm getting `timeout: timed out after 5000 msec waiting for something to happen`. \r\nAs for me this config looks exactly like the one in `snowflake` (tests from snowflake are running well) but they still doesn't work and I can't figure out why. Will appreciate if someone can help me as there isn't much information about RN testing, especially with Jest.\r\n\r\nIf this is an inappropriate question/issue - feel free to close it.\r\n\r\nThanks."},"comment":{"url":"https://api.github.com/repos/bartonhammond/snowflake/issues/comments/176495365","html_url":"https://github.com/bartonhammond/snowflake/issues/48#issuecomment-176495365","issue_url":"https://api.github.com/repos/bartonhammond/snowflake/issues/48","id":176495365,"user":{"login":"larubbio","id":51527,"avatar_url":"https://avatars.githubusercontent.com/u/51527?v=3","gravatar_id":"","url":"https://api.github.com/users/larubbio","html_url":"https://github.com/larubbio","followers_url":"https://api.github.com/users/larubbio/followers","following_url":"https://api.github.com/users/larubbio/following{/other_user}","gists_url":"https://api.github.com/users/larubbio/gists{/gist_id}","starred_url":"https://api.github.com/users/larubbio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/larubbio/subscriptions","organizations_url":"https://api.github.com/users/larubbio/orgs","repos_url":"https://api.github.com/users/larubbio/repos","events_url":"https://api.github.com/users/larubbio/events{/privacy}","received_events_url":"https://api.github.com/users/larubbio/received_events","type":"User","site_admin":false},"created_at":"2016-01-29T00:26:48Z","updated_at":"2016-01-29T00:26:48Z","body":"That error is why I had to move to npm3.  It installs dependencies flat which removes the conflict. I think you might also be able to resolve it by directly installing fbjs."}}