{"action":"created","issue":{"url":"https://api.github.com/repos/nolimits4web/Swiper/issues/1233","labels_url":"https://api.github.com/repos/nolimits4web/Swiper/issues/1233/labels{/name}","comments_url":"https://api.github.com/repos/nolimits4web/Swiper/issues/1233/comments","events_url":"https://api.github.com/repos/nolimits4web/Swiper/issues/1233/events","html_url":"https://github.com/nolimits4web/Swiper/pull/1233","id":68196044,"number":1233,"title":"fixed issue with running mocha tests that include this library","user":{"login":"ryanzec","id":444206,"avatar_url":"https://avatars.githubusercontent.com/u/444206?v=3","gravatar_id":"","url":"https://api.github.com/users/ryanzec","html_url":"https://github.com/ryanzec","followers_url":"https://api.github.com/users/ryanzec/followers","following_url":"https://api.github.com/users/ryanzec/following{/other_user}","gists_url":"https://api.github.com/users/ryanzec/gists{/gist_id}","starred_url":"https://api.github.com/users/ryanzec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryanzec/subscriptions","organizations_url":"https://api.github.com/users/ryanzec/orgs","repos_url":"https://api.github.com/users/ryanzec/repos","events_url":"https://api.github.com/users/ryanzec/events{/privacy}","received_events_url":"https://api.github.com/users/ryanzec/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-04-13T21:15:05Z","updated_at":"2015-04-15T14:47:57Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/nolimits4web/Swiper/pulls/1233","html_url":"https://github.com/nolimits4web/Swiper/pull/1233","diff_url":"https://github.com/nolimits4web/Swiper/pull/1233.diff","patch_url":"https://github.com/nolimits4web/Swiper/pull/1233.patch"},"body":"If I include this library with browserify and try to run my unit test, I get this error:\r\n\r\n```\r\n    Swiper.prototype = {\r\n    ^\r\nReferenceError: Swiper is not defined\r\n```\r\n\r\nThis is because most of the use cases of using the variable `Swiper` assume a browser.  I have slightly modified the code so that the initial creation uses `var Swiper = ...` instead of `window.Swiper = ...`.  At the end of the main file, I then do a `window.Swiper = Swiper;` to make sure it is available globally like it is now.  I also updated the amd script to use `window.Swiper` instead of just `Swiper` (which was just inferring the `window.` anyways).\r\n\r\nI tested some of the examples (since there don't seem to be able unit tests) and everything worked fine.  If this could be merged and a new version pushed to npm that would be great (otherwise I will have to push my own version to npm to continue on with my project since I need my tests to pass).\r\n\r\nLet me know if there is anything I need to change."},"comment":{"url":"https://api.github.com/repos/nolimits4web/Swiper/issues/comments/93430126","html_url":"https://github.com/nolimits4web/Swiper/pull/1233#issuecomment-93430126","issue_url":"https://api.github.com/repos/nolimits4web/Swiper/issues/1233","id":93430126,"user":{"login":"ryanzec","id":444206,"avatar_url":"https://avatars.githubusercontent.com/u/444206?v=3","gravatar_id":"","url":"https://api.github.com/users/ryanzec","html_url":"https://github.com/ryanzec","followers_url":"https://api.github.com/users/ryanzec/followers","following_url":"https://api.github.com/users/ryanzec/following{/other_user}","gists_url":"https://api.github.com/users/ryanzec/gists{/gist_id}","starred_url":"https://api.github.com/users/ryanzec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryanzec/subscriptions","organizations_url":"https://api.github.com/users/ryanzec/orgs","repos_url":"https://api.github.com/users/ryanzec/repos","events_url":"https://api.github.com/users/ryanzec/events{/privacy}","received_events_url":"https://api.github.com/users/ryanzec/received_events","type":"User","site_admin":false},"created_at":"2015-04-15T14:47:56Z","updated_at":"2015-04-15T14:47:56Z","body":"I don't see how this would break any of them (I can guarantee it does not break browserify since I am currently using this exactly code with browserify).  All I am doing is instead of directly assigning `Swiper` to the `window` global variable at the top of the file I am assigning it is a scoped variable at the top and then assigning it to the `window` global variable at the bottom of the same scoped function.  Assuming the `window` variable is available (which the current code does) prevents this code from being able to be included outside the context of a browser (like within mocha unit tests).\r\n\r\nBear in mind that I know Swiper itself will not function properly outside the context of the browser however without this change, I can't even load the code for my mocha tests (without removing the inclusion of this npm module within my code which then defeat the purpose of being able to install this package as a npm module)."}}