chrome-runtime-connect
Purpose
Disclaimer: This is incomplete for now, still a work in progress but nonetheless usable for simple cases.
This package allows to test the communication between a background page and a
content script.
It emulates the chomer.runtime.Port
interface
(doc.
Install
yarn add chrome-runtime-connect
Usage
// a. Call this to extend the global scope with `chrome.runtime`; // b. Or call this to have a `runtime` objectconst chromeRuntime = ;
Since the runtime API is exposed globally (using method a), in your tests your content scripts will be able to use the runtime API as-is.
Note: This is most useful when used it combination of a browser implementation such as jsdom.
TODO
- Add tests
- Implement the rest of the API (eg. disconnect)