document.cookie is like a string, but it is not a string. To quote the example from the Mozilla doc:
document.cookie
document.cookie = \"name=oeschger\"; docume
I figured out that jasmine has spyOnProperty which can be used for when you want to spy on getter and setters of objects. So I solved my issue with this:
spyOnProperty
const cookie: string = 'my-cookie=cookievalue;'; spyOnProperty(document, 'cookie', 'get').and.returnValue(cookie);