As I write a Jasmine corner test for printing iframes, but it shows "Unable to read property" open "from undefined". Below is a snippet of code
Source code: $scope.print = function() { var iFrame = document.getElementById("printingFrame"); var iFrameDoc = iFrame.contentDocument; iFrameDoc.open(); var contents = "text"; iFrameDoc.write(contents); iFrameDoc.close(); iFrame.contentWindow.focus(); iFrame.contentWindow.print(); }; Test Case: describe("just a test", function () { it("should print iframe content", function () { locals.$scope.print(); }); }); Error: TypeError: Cannot read property 'open' of undefined
Does anyone know why the next unit test fails?
source share