{"action":"created","issue":{"url":"https://api.github.com/repos/modeset/teaspoon/issues/351","labels_url":"https://api.github.com/repos/modeset/teaspoon/issues/351/labels{/name}","comments_url":"https://api.github.com/repos/modeset/teaspoon/issues/351/comments","events_url":"https://api.github.com/repos/modeset/teaspoon/issues/351/events","html_url":"https://github.com/modeset/teaspoon/issues/351","id":69852170,"number":351,"title":"Looking for Info on Fixture Cleanup","user":{"login":"rstudner","id":209970,"avatar_url":"https://avatars.githubusercontent.com/u/209970?v=3","gravatar_id":"","url":"https://api.github.com/users/rstudner","html_url":"https://github.com/rstudner","followers_url":"https://api.github.com/users/rstudner/followers","following_url":"https://api.github.com/users/rstudner/following{/other_user}","gists_url":"https://api.github.com/users/rstudner/gists{/gist_id}","starred_url":"https://api.github.com/users/rstudner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rstudner/subscriptions","organizations_url":"https://api.github.com/users/rstudner/orgs","repos_url":"https://api.github.com/users/rstudner/repos","events_url":"https://api.github.com/users/rstudner/events{/privacy}","received_events_url":"https://api.github.com/users/rstudner/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/modeset/teaspoon/labels/bug","name":"bug","color":"fc2929"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2015-04-21T13:55:56Z","updated_at":"2015-04-21T19:29:44Z","closed_at":"2015-04-21T17:40:51Z","body":"So I am writing some tests against code using KnockoutJS.\r\n\r\nA key idea of Knockout is \"dont apply the bindings twice\".\r\n\r\nso if I load up an html fixture in beforeEach.. and then have \"2 tests\".  The 2nd test will fail, claiming I already applied the knockout bindings.\r\n\r\nThis implies that between each test, the fixture/UI isn't actually getting blown away.\r\n\r\nAm I missing some small detail (or giant obvious thing haha) in regards to this?\r\n\r\n(I can just put if (!appliedBindings) { ko.applyBindings(); appliedBindings = true; } kind of things in *all* the JS, but that never feels right of course)\r\n\r\nto note - the actual code never does \"this twice\" and all the pages work 100% in general."},"comment":{"url":"https://api.github.com/repos/modeset/teaspoon/issues/comments/94913021","html_url":"https://github.com/modeset/teaspoon/issues/351#issuecomment-94913021","issue_url":"https://api.github.com/repos/modeset/teaspoon/issues/351","id":94913021,"user":{"login":"rstudner","id":209970,"avatar_url":"https://avatars.githubusercontent.com/u/209970?v=3","gravatar_id":"","url":"https://api.github.com/users/rstudner","html_url":"https://github.com/rstudner","followers_url":"https://api.github.com/users/rstudner/followers","following_url":"https://api.github.com/users/rstudner/following{/other_user}","gists_url":"https://api.github.com/users/rstudner/gists{/gist_id}","starred_url":"https://api.github.com/users/rstudner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rstudner/subscriptions","organizations_url":"https://api.github.com/users/rstudner/orgs","repos_url":"https://api.github.com/users/rstudner/repos","events_url":"https://api.github.com/users/rstudner/events{/privacy}","received_events_url":"https://api.github.com/users/rstudner/received_events","type":"User","site_admin":false},"created_at":"2015-04-21T19:29:44Z","updated_at":"2015-04-21T19:29:44Z","body":"jejacks0n - no no.. i'm taking your advice 100% well :)\r\n\r\nI think wht is going on, is that when smoeone (me) is saying:\r\nko.applyBindings(jsonObject) without qualifying *to what*, it is then applying itself to \"all of the DOM\".. only a part of which (albeit a large part) is the fixgture that is coming and going.\r\n\r\nThus, knockout says: \"Wait a second, i've been applied to this global space already\"\r\n\r\nAnd yes -- if I call PortalAppliances.init() \"twice\" in code on the same page, it gets the same error.\r\n\r\nSo, what i'm trying, to just wrapping the entire fixture in a div:\r\n<div id=\"appliancesExperience\">\r\netc\r\n</div>\r\nand doing ko.applyBindings(jsonObject, document.getElementById('appliancesExperience'));\r\n\r\nThis, seems to make it happier.\r\n\r\nYou comment about fixture cleanup, that I listened to (hah) led me precisely to trying this.\r\n"}}