Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to make it work with sinon-chrome in tests #218

Closed
dsrini-open opened this issue Jan 24, 2020 · 3 comments
Closed

How to make it work with sinon-chrome in tests #218

dsrini-open opened this issue Jan 24, 2020 · 3 comments

Comments

@dsrini-open
Copy link

dsrini-open commented Jan 24, 2020

With the Fix 190 [https://github.com//pull/190], the polyfill does not work on outside extension context.
What about the tests? Have imported in each page in source files using -
import browser from "webextension-polyfill";
which is causing the tests to fail with -

Error: This script should only be loaded in a browser extension.

@Rob--W
Copy link
Member

Rob--W commented Jan 25, 2020

How are you running tests?

@dsrini-open
Copy link
Author

dsrini-open commented Feb 11, 2020

@Rob--W - Through mocha. I am using sinon-chrome for test purposes.

Meanwhile the workaround that I found is the following -

  if (!chrome.runtime) chrome.runtime = {};
  if (!chrome.runtime.id) chrome.runtime.id = "history-delete";

Having this in the setup.js file, running it first before everything works.

@Rob--W
Copy link
Member

Rob--W commented Feb 12, 2020

Just chrome.runtime.id = "testid"; should be sufficient. sinon-chrome does declare a chrome.runtime.id property, but its value is null, which caused the duck-typing to fail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants