Reputation: 59
I'm building a Chrome extension that removes some content from a website. I wanted to set up some integration and e2e tests on it in order to check...
chrome.storage
APII'm a beginner in testing and I'm struggling to figure out what would be the best approach. Here's the options I've looked at so far:
chrome.storage
API.Is Selenium still the only option in 2021 for testing Chrome extensions?
Upvotes: 3
Views: 1841
Reputation: 121
Playwright supports testing of Chrome extensions out of the box and it's covering your 3 questions:
test('setting storage key during a test', async ({ page, backgroundPage }) => {
await backgroundPage.evaluate(() => {
chrome.storage.sync.set('SomeKey', 'SomeValue');
})
...
});
backgroundPage
is coming from a fixture that should define like explained in the article (depending if you extension run in manifest v2 or v3).
chrome-extension://
like your popup.html, simply like this :test('popup page', async ({ page, extensionId }) => {
await page.goto(`chrome-extension://${extensionId}/popup.html`);
await expect(page.locator('body')).toHaveText('my-extension popup');
});
Upvotes: 4
Reputation: 59
After working on it for a week, I came to the conclusion that the best way to do this is with Selenium and Jest. The setup takes a bit to get used to it, but once you do it's pretty straightforward. My resources:
Upvotes: 1