StackShareStackShare
Follow on
StackShare

Discover and share technology stacks from companies around the world.

Follow on

© 2025 StackShare. All rights reserved.

Product

  • Stacks
  • Tools
  • Feed

Company

  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Service
  1. Stackups
  2. Application & Data
  3. Languages
  4. Npm Packages
  5. proxyquire vs rewire

proxyquire vs rewire

OverviewComparisonAlternatives

Overview

proxyquire
proxyquire
Stacks578
Followers0
Votes0
GitHub Stars2.7K
Forks154
rewire
rewire
Stacks265
Followers0
Votes0
GitHub Stars3.1K
Forks149

proxyquire vs rewire: What are the differences?

<Proxyquire and rewire are two commonly used tools in JavaScript to help with mocking dependencies during testing. Proxyquire is a library specifically designed for stubbing require calls, while rewire allows you to directly access and modify private variables within a module. Both tools can be useful for testing, but they have distinct differences in their functionality and usage.>

  1. Integration Level: Proxyquire operates at the integration level where it manipulates the require cache to substitute modules, while rewire works at a lower level by directly manipulating the module's content before it's loaded.
  2. Accessible Variables: Proxyquire allows you to stub the entire module or specific methods, but it doesn't provide direct access to private variables. In contrast, rewire enables you to access and modify private variables by bypassing the module system's encapsulation.
  3. Dependency Injection: Proxyquire excels at injecting dependencies or replacing modules during testing, making it easier to isolate components. Rewire, on the other hand, focuses on tweaking internal module behavior by manipulating variables within the module scope.
  4. Syntax and API: Proxyquire provides a simple syntax for stubbing require calls and offers clear documentation on how to use it effectively. Rewire introduces a different API for accessing and modifying module variables, requiring developers to follow specific patterns to achieve the desired results.
  5. Performance Impact: Since Proxyquire interacts with the require cache, it may have a higher performance overhead compared to rewire, which directly modifies module variables. Depending on the testing scenario and the extent of modifications needed, this difference in performance impact can be a crucial factor to consider.
  6. Community Support and Maintenance: Proxyquire has been widely adopted and maintained by the community, ensuring regular updates and bug fixes. Rewire, while still utilized by developers, may have a smaller community following, leading to potential concerns about long-term support and compatibility with newer JavaScript frameworks and tools.

In Summary, Proxyquire and rewire offer distinct approaches to mocking dependencies in JavaScript testing, with Proxyquire focusing on integrating with require calls and replacing modules, while rewire allows direct access and modification of private variables within modules.

Share your Stack

Help developers discover the tools you use. Get visibility for your team's tech choices and contribute to the community's knowledge.

View Docs
CLI (Node.js)
or
Manual

Detailed Comparison

proxyquire
proxyquire
rewire
rewire

Proxies nodejs require in order to allow overriding dependencies during testing.

Easy dependency injection for node.js unit testing.

Statistics
GitHub Stars
2.7K
GitHub Stars
3.1K
GitHub Forks
154
GitHub Forks
149
Stacks
578
Stacks
265
Followers
0
Followers
0
Votes
0
Votes
0

What are some alternatives to proxyquire, rewire?

typescript

typescript

TypeScript is a language for application scale JavaScript development.

eslint

eslint

An AST-based pattern checker for JavaScript.

react

react

React is a JavaScript library for building user interfaces.

@types/node

@types/node

TypeScript definitions for Node.js.

prettier

prettier

Prettier is an opinionated code formatter.

react-dom

react-dom

React package for working with the DOM.

jest

jest

Delightful JavaScript Testing.

express

express

Fast, unopinionated, minimalist web framework.

mocha

mocha

Simple, flexible, fun test framework.

webpack

webpack

Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.

Related Comparisons

Bootstrap
Materialize

Bootstrap vs Materialize

Laravel
Django

Django vs Laravel vs Node.js

Bootstrap
Foundation

Bootstrap vs Foundation vs Material UI

Node.js
Spring Boot

Node.js vs Spring-Boot

Liquibase
Flyway

Flyway vs Liquibase