Lusito / webextension-polyfill-ts

This is a TypeScript ready "wrapper" for the WebExtension browser API Polyfill by Mozilla

Repository from Github https://github.comLusito/webextension-polyfill-tsRepository from Github https://github.comLusito/webextension-polyfill-ts

This script should only be loaded in a browser extension. - Error only during Jest usage

BartoszKlonowski opened this issue · comments

Hello!

I'm having a hard time setting up this project in a correct way, perhaps I'm missing something in the docs, but I couldn't figure out what exactly.

So the problem is, that when using the webextension-polyfill for the app I implement, everything works just great (thank you!), but when I try to use it for tests (Jest environment, without any other test frameworks or libs) I get:

  ● Test suite failed to run

    This script should only be loaded in a browser extension.

      1 | import React, {useEffect, useState} from "react";
      2 | import {getActiveTabDomainFromURL, getWebsiteIconObject, Icon} from "../Utils";
    > 3 | import browser from "webextension-polyfill";
        | ^

So what I did to install and use this project was basically follow the setup guide, but having Jest already up and running.

If there's any more info I can provide you with to support me, let me know please.

Hi @BartoszKlonowski,

sorry for the delay. Your link goes to mockzilla, not mockzilla-webextension. Please take a look at https://lusito.github.io/mockzilla-webextension/setup.html instead. Mockzilla by itself does nothing with webextensions.