We have several situations where our Polymer elements have methods that rely on global behaviour, such as viewport size detection, or an analytics package that injects a global variable.
Now I'm trying to test these methods using Web Component Tester, but I can't see how to inject e.g. stubs into the window
object (e.g. like is possible with webdriver's execute function). How do I do this?
An example of a test that didn't work:
test('my-element should not crash when `Analytics` is blocked', function () {
// I'd like window.Analytics in my app to be undefined,
// but this doesn't work, obviously:
window.Analytics = undefined;
myEl = fixture('my-element');
expect(myEl.ready).to.not.throw();
});