I have a JavaScript function with "document.write" in it, as below:
function sampleFunction(){
document.write('hello world');
}
And, for this wrote a unit test case in Jasmine, as below:
describe("testing function", function() {
it("should give output", function() {
expect(sampleFunction()).toBe('hello world');
expect(sampleFunction()).toContain('hello');
});
});
But when we run it using Karma, it opens up a web page just print 'hello world' on it and test case fails.
Can you please suggest what is the correct way to write unit test case for this function
Many Thanks!