{"action":"created","issue":{"url":"https://api.github.com/repos/reactjs/redux/issues/1716","repository_url":"https://api.github.com/repos/reactjs/redux","labels_url":"https://api.github.com/repos/reactjs/redux/issues/1716/labels{/name}","comments_url":"https://api.github.com/repos/reactjs/redux/issues/1716/comments","events_url":"https://api.github.com/repos/reactjs/redux/issues/1716/events","html_url":"https://github.com/reactjs/redux/issues/1716","id":154308134,"number":1716,"title":"Document a simpler way to test async action creators","user":{"login":"gaearon","id":810438,"avatar_url":"https://avatars.githubusercontent.com/u/810438?v=3","gravatar_id":"","url":"https://api.github.com/users/gaearon","html_url":"https://github.com/gaearon","followers_url":"https://api.github.com/users/gaearon/followers","following_url":"https://api.github.com/users/gaearon/following{/other_user}","gists_url":"https://api.github.com/users/gaearon/gists{/gist_id}","starred_url":"https://api.github.com/users/gaearon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gaearon/subscriptions","organizations_url":"https://api.github.com/users/gaearon/orgs","repos_url":"https://api.github.com/users/gaearon/repos","events_url":"https://api.github.com/users/gaearon/events{/privacy}","received_events_url":"https://api.github.com/users/gaearon/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/reactjs/redux/labels/docs","name":"docs","color":"5319e7"},{"url":"https://api.github.com/repos/reactjs/redux/labels/feedback%20wanted","name":"feedback wanted","color":"207de5"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-05-11T18:15:46Z","updated_at":"2016-05-20T07:59:41Z","closed_at":null,"body":"Since Redux Thunk 2.1.0, we can do something like this:\r\n\r\n```js\r\nimport * as api from '../api'\r\n\r\nexport default function configureStore(mocks) {\r\n  return createStore(\r\n    reducer,\r\n    applyMiddleware(thunk.withExtraArgument({\r\n      api,\r\n      // can also pass other modules you need in ACs and want to mock in tests\r\n    }))\r\n  );\r\n}\r\n````\r\n\r\nYour action creators now don’t depend on those modules:\r\n\r\n```js\r\nexport function getUser(id) {\r\n  return (dispatch, getState, { api }) =>\r\n    api.getUser(id).then(() => dispatch({ ... }))\r\n  }\r\n}\r\n```\r\n\r\nIn tests, you should be able to call them directly with spies and pass your mocks as the third argument.\r\nLooks perfectly testable to me. Seems like there is need for a third-party library.\r\n\r\nWhat am I missing?\r\n\r\ncc @arnaudbenard"},"comment":{"url":"https://api.github.com/repos/reactjs/redux/issues/comments/220540347","html_url":"https://github.com/reactjs/redux/issues/1716#issuecomment-220540347","issue_url":"https://api.github.com/repos/reactjs/redux/issues/1716","id":220540347,"user":{"login":"arnaudbenard","id":1458008,"avatar_url":"https://avatars.githubusercontent.com/u/1458008?v=3","gravatar_id":"","url":"https://api.github.com/users/arnaudbenard","html_url":"https://github.com/arnaudbenard","followers_url":"https://api.github.com/users/arnaudbenard/followers","following_url":"https://api.github.com/users/arnaudbenard/following{/other_user}","gists_url":"https://api.github.com/users/arnaudbenard/gists{/gist_id}","starred_url":"https://api.github.com/users/arnaudbenard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arnaudbenard/subscriptions","organizations_url":"https://api.github.com/users/arnaudbenard/orgs","repos_url":"https://api.github.com/users/arnaudbenard/repos","events_url":"https://api.github.com/users/arnaudbenard/events{/privacy}","received_events_url":"https://api.github.com/users/arnaudbenard/received_events","type":"User","site_admin":false},"created_at":"2016-05-20T07:59:41Z","updated_at":"2016-05-20T07:59:41Z","body":"Great addition to the `redux-thunk` API. It looks testable to me."}}
{"actor":{"display_login":"arnaudbenard"}}