I need to dynamically create an iframe with some HTML and test it with Jasmine.
This is a way how I create an Iframe - Creating an iframe with given HTML dynamically
var iframe;
beforeEach(() => {
iframe = document.createElement('iframe');
var html = '<body><div class="bar">Foo</div></body>';
document.body.appendChild(iframe);
iframe.contentWindow.document.open();
iframe.contentWindow.document.write(html);
iframe.contentWindow.document.close();
});
But there is no content created inside that iframe:
it('working with IFRAME',
inject([SomeAngular2Component],
(component: SomeAngular2Component) => {
console.log(iframe) // -> <iframe></iframe> NO INNER HTML HERE
//component.methodForIframe.(iframe);
//expect().toBe();
}));
Any ideas?
Thanks!!