revdev
revdev
PD🧩 Plasmo Developers
Created by revdev on 3/9/2024 in #👾extension
How to mock storage
Hey guys, im fairly new with plasmo. currently writing e2e tests with playwright. How can i properly mock a call to "storage.get" or atleast prefill the value? first idea was to just manually set it like that in the context of the browser:
await page.addInitScript(() => {
chrome.storage.sync.set({
token: process.env.TOKEN
})
});
await page.addInitScript(() => {
chrome.storage.sync.set({
token: process.env.TOKEN
})
});
but for some reason it doesnt pick it up. the storage itself is created like that:
import { Storage } from '@plasmohq/storage';

const storage = new Storage();
import { Storage } from '@plasmohq/storage';

const storage = new Storage();
so i guess the sync storageArea should be fine since its the default.
1 replies