Automatically generated sinon stubs for the WebExtensions API, designed to make browser extension testing easy. Version 1.0.0 uses the Firefox 72.0.2 schema and provides TypeScript types. Sinon is a peer dependency, not bundled, to avoid instanceof issues. Includes API and CLI to update schema to latest stable Firefox via webextensions-schema. Produces a fresh sandbox per call, with sinonSandbox exposed. Ideal for unit testing WebExtensions against sinon assertions and stubs.
npm install webextensions-api-mockNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a WebExtensions API mock, calls a method, asserts stub behavior, triggers event listeners, and resets history.
Run `webextensions-api-mock update` to sync to latest Firefox stable schema, or manually update via API.
Install sinon as devDependency: npm install --save-dev sinon webextensions-api-mock
Create a new browserMock() in each test or use beforeEach to reset via browser.sinonSandbox.reset()
Pass mock arguments to yield() to simulate event data: browser.tabs.onCreated.addListener.yield({ id: 1, url: '...' });npm install --save-dev sinon@^7.5.0
const browser = browserMock();
Run `webextensions-api-mock update` to get latest schema, or check Firefox version compatibility.
Use browser.sinonSandbox.resetHistory() (note: 'sinonSandbox' with capital S).