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

Using in a Unit Testing environment #236

Closed
davestewart opened this issue Aug 29, 2020 · 6 comments
Closed

Using in a Unit Testing environment #236

davestewart opened this issue Aug 29, 2020 · 6 comments

Comments

@davestewart
Copy link

Not sure if this is the right place to ask, but when attempting to use in Jest tests, I get the following error:

This script should only be loaded in a browser extension

I was attempting to use in conjunction with sinon-chrome to mock the Browser API and begin to test my extension, but I can't seem to get the chrome object in the right context for the polyfill to work:

acvetkov/sinon-chrome#103

I'm a "fair weather" tester, so I will be the first to admit I may have no idea what I'm doing and perhaps should not be tackling things this way.

Can anyone advise?

Thank you.

@nickserv
Copy link

This fixed it for me #218 (comment)

@Rob--W
Copy link
Member

Rob--W commented Sep 1, 2020

Duplicate of #218. Thanks nick for linking #218 (comment)

@Rob--W Rob--W closed this as completed Sep 1, 2020
@davestewart
Copy link
Author

Thanks @nickmccurdy and @Rob--W!

Not sure why I didn't search the issues.

Not sure if you consider it in-scope to perhaps add a section (even links) to the home page?

It's really the next logical step for anything you expect to be used my more than a few people.

Thanks again 👍

@Rob--W
Copy link
Member

Rob--W commented Sep 1, 2020

I think that the best way to solve this bug is to set a non-void extension ID in chrome.runtime.id in the sinon-chrome library (or at least document it there). This "problem" is not specific to this polyfill, but generally to any consumer of sinon-chrome.

@nickserv
Copy link

nickserv commented Sep 1, 2020

Should we suggest a fix upstream? It seems like a common issue, I'm not sure why it's initialized to null.

@Rob--W
Copy link
Member

Rob--W commented Sep 1, 2020

It wouldn't hurt to ask. sinon-chrome's primary responsibility seems to be the generation of stubs, and it's up to the consumers of that library to provide meaningful implementations. In this case, a value for chrome.runtime.id.

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

3 participants