{"action":"created","issue":{"url":"https://api.github.com/repos/speedskater/babel-plugin-rewire/issues/85","labels_url":"https://api.github.com/repos/speedskater/babel-plugin-rewire/issues/85/labels{/name}","comments_url":"https://api.github.com/repos/speedskater/babel-plugin-rewire/issues/85/comments","events_url":"https://api.github.com/repos/speedskater/babel-plugin-rewire/issues/85/events","html_url":"https://github.com/speedskater/babel-plugin-rewire/issues/85","id":124331087,"number":85,"title":"Rewire Flux stores which are singletons","user":{"login":"kbiedrzycki","id":3285274,"avatar_url":"https://avatars.githubusercontent.com/u/3285274?v=3","gravatar_id":"","url":"https://api.github.com/users/kbiedrzycki","html_url":"https://github.com/kbiedrzycki","followers_url":"https://api.github.com/users/kbiedrzycki/followers","following_url":"https://api.github.com/users/kbiedrzycki/following{/other_user}","gists_url":"https://api.github.com/users/kbiedrzycki/gists{/gist_id}","starred_url":"https://api.github.com/users/kbiedrzycki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kbiedrzycki/subscriptions","organizations_url":"https://api.github.com/users/kbiedrzycki/orgs","repos_url":"https://api.github.com/users/kbiedrzycki/repos","events_url":"https://api.github.com/users/kbiedrzycki/events{/privacy}","received_events_url":"https://api.github.com/users/kbiedrzycki/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-12-30T10:30:25Z","updated_at":"2016-01-06T20:29:38Z","closed_at":null,"body":"I am looking for solution how to use rewire babel plugin with Flux stores, which are basically singletons. According to this article http://bensmithett.com/testing-flux-stores-without-jest/ each rewire() call returns fresh singleton instance, but not sure how can I acheive same effect using babel plugin (or is it even possible?). I am also usign webpack configuration for that, as far as I saw I have access to whole Rewire API inside Flux Store, but I couldn't reset stores' state. Any thoughts on that?"},"comment":{"url":"https://api.github.com/repos/speedskater/babel-plugin-rewire/issues/comments/169451970","html_url":"https://github.com/speedskater/babel-plugin-rewire/issues/85#issuecomment-169451970","issue_url":"https://api.github.com/repos/speedskater/babel-plugin-rewire/issues/85","id":169451970,"user":{"login":"speedskater","id":1639779,"avatar_url":"https://avatars.githubusercontent.com/u/1639779?v=3","gravatar_id":"","url":"https://api.github.com/users/speedskater","html_url":"https://github.com/speedskater","followers_url":"https://api.github.com/users/speedskater/followers","following_url":"https://api.github.com/users/speedskater/following{/other_user}","gists_url":"https://api.github.com/users/speedskater/gists{/gist_id}","starred_url":"https://api.github.com/users/speedskater/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/speedskater/subscriptions","organizations_url":"https://api.github.com/users/speedskater/orgs","repos_url":"https://api.github.com/users/speedskater/repos","events_url":"https://api.github.com/users/speedskater/events{/privacy}","received_events_url":"https://api.github.com/users/speedskater/received_events","type":"User","site_admin":false},"created_at":"2016-01-06T20:29:38Z","updated_at":"2016-01-06T20:29:38Z","body":"@kbiedrzycki sorry for the late answer. Regarding your request using this plugin you are not able to retrieve a fresh singleton, but you can rewire all local variables and all imports used inside of the module where the singleton is located. Maybe this will allow you to achieve your required behavior. \r\nAnother approach is to use an architecture like redux where stores are simple reducer function which itself store no state and hence are very easy to test. \r\nPlease let me know if this answer is sattisfying for you."}}