To mock object for document element with Jasmine and JavaScript, we use the createSpy method.
For instance, we write
const dummyElement = document.createElement("div");
document.getElementById = jasmine
.createSpy("HTML Element")
.and.returnValue(dummyElement);
to call createSpy to create a spy and make it return a value with returnValue.
And we set that as the value of document.getElementById.
Conclusion
To mock object for document element with Jasmine and JavaScript, we use the createSpy method.