{"action":"created","issue":{"url":"https://api.github.com/repos/Polymer/web-component-tester/issues/357","repository_url":"https://api.github.com/repos/Polymer/web-component-tester","labels_url":"https://api.github.com/repos/Polymer/web-component-tester/issues/357/labels{/name}","comments_url":"https://api.github.com/repos/Polymer/web-component-tester/issues/357/comments","events_url":"https://api.github.com/repos/Polymer/web-component-tester/issues/357/events","html_url":"https://github.com/Polymer/web-component-tester/issues/357","id":168812149,"number":357,"title":"Stubbing fixture element appears to cause next fixture load to fail","user":{"login":"akc42","id":368238,"avatar_url":"https://avatars.githubusercontent.com/u/368238?v=3","gravatar_id":"","url":"https://api.github.com/users/akc42","html_url":"https://github.com/akc42","followers_url":"https://api.github.com/users/akc42/followers","following_url":"https://api.github.com/users/akc42/following{/other_user}","gists_url":"https://api.github.com/users/akc42/gists{/gist_id}","starred_url":"https://api.github.com/users/akc42/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akc42/subscriptions","organizations_url":"https://api.github.com/users/akc42/orgs","repos_url":"https://api.github.com/users/akc42/repos","events_url":"https://api.github.com/users/akc42/events{/privacy}","received_events_url":"https://api.github.com/users/akc42/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-08-02T06:52:19Z","updated_at":"2016-08-02T12:16:21Z","closed_at":null,"body":"I have a fixture something like this\r\n\r\n```\r\n<test-fixture id=\"basic\">\r\n  <template>\r\n    <pas-app unresolved></pas-app>\r\n  </template>\r\n</test-fixture>\r\n```\r\nThe unresolved attribute is removed by pas-app element in the attached callback.\r\n\r\nVarious aspects of it are instantiated, then items replaced then stubbing occurs in nested describe, beforeEach pairs. In particular a session element is replaced by a mock\r\n\r\n```\r\n      beforeEach(function(done) {\r\n        app=fixture('basic');\r\n        stub('iron-ajax', {\r\n          generateRequest: function() {\r\n            //make a noop;\r\n          }\r\n        });\r\n        replace('pas-session').with('test-session');\r\n        flush(done);\r\n      });\r\n```\r\n\r\nAt one point in my test sequence I am trying to check that it calls importHref to lazily load an element so I stub it like this\r\n\r\n```\r\n       it('should try and load pas-pages', function(done) {\r\n          var called = false;\r\n          stub('pas-app', {\r\n            importHref: function(href,onload,onerror,async) {\r\n              called = href;\r\n            }\r\n          });\r\n          session.user = {name: 'LoggonOnUser'};\r\n          flush(function() {\r\n            expect(called.slice(-14)).to.equal('pas-pages.html'); \r\n            done();\r\n          });\r\n\r\n        });\r\n```\r\n\r\nThis test passes, but if I now put a breakpoint on the next time I hit the beforeEach function above,  before I call fixture('basic') the dom shows a fixture with a completely empty document fragment, and after I have called fixture('basic'), the pas-app element is there but remains un-resolved and its template is not stamped out \r\n\r\nThe test that I refer to above output some pretty heavy error messages to the console\r\n\r\n```\r\nCannot read property 'parentNode' of undefined\r\n                           Function.invoke at /bower_components/sinonjs/sinon.js:2621\r\n  test-session.proxy [as instanceTemplate] (eval at createProxy at /bower_components/sinonjs/sinon.js:2526:17), <anonymous>:1\r\n               test-session._stampTemplate at /bower_components/polymer/polymer-mini.html:25\r\n                test-session._initFeatures at /bower_components/polymer/polymer.html:3914\r\n              test-session.createdCallback at /bower_components/polymer/polymer-micro.html:190\r\n                           Function.invoke at /bower_components/sinonjs/sinon.js:2621\r\n  pas-app.proxy [as instanceTemplate] (eval at createProxy at /bower_components/sinonjs/sinon.js:2526:17), <anonymous>:1\r\n                    pas-app._stampTemplate at /bower_components/polymer/polymer-mini.html:25\r\n```"},"comment":{"url":"https://api.github.com/repos/Polymer/web-component-tester/issues/comments/236886458","html_url":"https://github.com/Polymer/web-component-tester/issues/357#issuecomment-236886458","issue_url":"https://api.github.com/repos/Polymer/web-component-tester/issues/357","id":236886458,"user":{"login":"akc42","id":368238,"avatar_url":"https://avatars.githubusercontent.com/u/368238?v=3","gravatar_id":"","url":"https://api.github.com/users/akc42","html_url":"https://github.com/akc42","followers_url":"https://api.github.com/users/akc42/followers","following_url":"https://api.github.com/users/akc42/following{/other_user}","gists_url":"https://api.github.com/users/akc42/gists{/gist_id}","starred_url":"https://api.github.com/users/akc42/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akc42/subscriptions","organizations_url":"https://api.github.com/users/akc42/orgs","repos_url":"https://api.github.com/users/akc42/repos","events_url":"https://api.github.com/users/akc42/events{/privacy}","received_events_url":"https://api.github.com/users/akc42/received_events","type":"User","site_admin":false},"created_at":"2016-08-02T12:16:21Z","updated_at":"2016-08-02T12:16:21Z","body":"I refactored my tests so that I stub the top level element before calling replace. When I do that, all the indications are that replace hasn't done anything, although its not done so silently.  All that has happened is that some tests that passed when the replace did work, now act as though  the  replace hasn't happened.\r\n\r\nI must say I am really puzzled by what replace is actually doing.  With chrome dev tools and breakpoints I am looking at the dom  after each step, including a call to replace, and I can't see any identifiable change with replace.  Certainly there is no reference to the test-element, all the dom shows is the original element.\r\n\r\nShould I be calling replace just once, before I call fixture?"}}
{"actor":{"display_login":"akc42"}}