I am using Jasmine for unit testing, and document.cookie in my code. Is it possible to mock document.cookie in my test file ?
I found out that I could use this :
var mock = {
value_: '',
get cookie() {
return this.value_;
},
set cookie(value) {
this.value_ += value + ';';
}
};
But I don't know how to tell Javascript that I want to use this instead of the document.cookie ? Is it possible ?