문제

I'm mocking chrome.storage using jasmine's spyOn function like this:

this.fakeChromeStorage = {};
chrome = { storage: { sync: {get: function() {}, set: function() {}}}};
spyOn(chrome.storage.sync, 'get').and.callFake(function(key, callback) {
    callback();
});

But then when my application calls:

console.info(chrome.storage);
console.info(typeof chrome.storage);
console.info(chrome.storage.type);
console.info(typeof chrome.storage.type);

It prints:

[object Object]
object
undefined
undefined

How is this even possible?

도움이 되었습니까?

해결책

Yes, chrome.storage is an Object, chrome.storage.type is a property on the object chrome.storage which does not exists and therefor will be undefined.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top