By checking document.referrer, we find that this is a getter:

With Jasmine 2.6, you can create a spy to change the return value of any getter functions.
spyOnProperty(document, 'referrer', 'get').and.returnValue('http://foobar.com');
expect(document.referrer).toBe('http://foobar.com');
You can read more in the latest API documentation .
source
share