Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. WebExtensions
  3. sinon-chrome

sinon-chrome

ISCJavaScript2.3.2

A helper tool for unit-testing Chrome and Firefox extensions and apps in Node.js by mocking the browser API.

GitHubGitHub
441 stars47 forks0 contributors

What is sinon-chrome?

Sinon-chrome is a Node.js library for unit-testing Chrome and Firefox browser extensions and apps. It mocks the entire browser API using Sinon stubs and mock events, allowing developers to run tests without a real browser. It solves the problem of testing extension logic in isolation by providing a controlled, schema-accurate simulation of the Chrome and Firefox extension environments.

Target Audience

Developers building Chrome or Firefox extensions and apps who need to write unit tests in Node.js without browser dependency. It's particularly useful for teams integrating extension testing into CI/CD pipelines.

Value Proposition

Developers choose Sinon-chrome because it provides accurate, schema-based API mocks that match real browser behavior, integrates seamlessly with Sinon.js for familiar testing patterns, and eliminates the need for browser automation in unit tests.

Overview

Testing chrome extensions with Node.js

Use Cases

Best For

  • Unit testing Chrome extension logic in Node.js environments
  • Testing Firefox WebExtensions without launching a browser
  • Mocking Chrome API calls and events in isolation tests
  • Integrating extension tests into CI/CD pipelines without browser dependencies
  • Testing extension plugins like cookie or i18n functionality
  • Writing tests for extension modules that rely on chrome.* namespace APIs

Not Ideal For

  • Projects requiring testing against the latest Chrome or Firefox APIs
  • Teams needing end-to-end testing with actual browser rendering and UI interactions
  • Developers using testing frameworks that don't integrate with Sinon.js

Pros & Cons

Pros

Schema-Accurate API Mocks

Generates mocks using official Chromium and Firefox WebExtensions schemas, ensuring consistency with real browser APIs, as stated in the README under 'Schema support'.

Seamless Sinon Integration

Replaces Chrome API methods with Sinon stubs and events with mockable classes, enabling familiar testing patterns like .calledOnce and .withArgs, as shown in the examples.

Plugin System for Realism

Supports plugins like Cookie and i18n to emulate browser-specific behaviors, providing more realistic testing environments, as mentioned in the Plugins section.

Convenient Reset with Flush

Includes a flush method to reset stub behavior and properties to defaults, simplifying test cleanup, demonstrated in the stubs api examples.

Cons

Outdated API Schemas

The README admits schemas are from Chrome 53 and Firefox 49, which are old versions, potentially missing newer APIs and leading to inaccurate mocks for modern extensions.

Node.js Only Limitation

Primarily designed for Node.js testing, making it unsuitable for browser-based unit tests or environments that require actual browser execution, as highlighted in the 'How it works' section.

Sparse Plugin Documentation

Plugins like Cookie and i18n have minimal documentation on the wiki, which can hinder setup and usage for developers needing to emulate complex browser behaviors.

Complex Setup for Full Functionality

Accurate emulation often requires registering additional plugins, adding complexity compared to simpler mocking libraries, as noted in the Plugins section.

Frequently Asked Questions

Quick Stats

Stars441
Forks47
Contributors0
Open Issues36
Last commit4 years ago
CreatedSince 2014

Tags

#chrome-extensions#chrome#unit-testing#browser-api#mocking#nodejs#sinon#javascript#testing-tools#webextensions

Built With

N
Node.js

Included in

WebExtensions1.5k
Auto-fetched 12 hours ago

Related Projects

addons-linteraddons-linter

🔍 Firefox Add-ons linter, written in JavaScript. 👁

Stars356
Forks157
Last commit4 days ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub