jhnns/rewire
Easy monkey-patching for node.js unit tests observed · 2026-08-28
Health v2 · maintenance only
56/100
- Activity 56
- Release rhythm 31
- Longevity 100
How is this computed?
round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10) — computed 2026-09-03. Adoption (stars, forks) is never an input.
- gap_med: 36.0
- age_days: 5204
- days_rel: 383
- days_push: 265
- n_releases_24m: 3
Adoption not part of the score
3093 stars · 128 forks observed · 2026-08-28
What it is AI-extracted, prompt v1, taxonomy v1, 2026-08-30, confidence not recorded
rewire is a Node.js library that adds special setter and getter methods to CommonJS modules so tests can inject mocks, override private variables, and patch globals. It acts like require() but exposes __set__, __get__, and __with__ for modifying module internals during unit tests.
Use cases
- inject mocks for required modules like fs in unit tests
- inspect and override private variables of a module
- mock globals like process or console within a single module
- revert monkey-patched changes after a test runs
- test node.js modules with hard-to-mock dependencies
When to choose
- you test CommonJS Node.js modules and need to stub their internal dependencies
- you want to access or override module-private variables in tests
- you need scoped global mocking that doesn't leak to other modules
When to avoid
- your project uses ES modules, which rewire does not support
- you prefer dependency injection via constructor parameters or a DI framework
- you want modern alternatives like proxyquire or esm mocking
Facets
library · maturity active
mocking testing testing developer-tools backend monkey-patching dependency-injection unit-testing commonjs nodejs javascript
2 sources
- readme: https://github.com/jhnns/rewire · fetched 2026-08-28 · 7690f364a408
- registry_npm: https://registry.npmjs.org/rewire · fetched 2026-08-29 · bf9c7b9aadeb
Member repositories
| Repository | Role | Health v2 |
|---|---|---|
| jhnns/rewire | main | 56 |
For agents
Data as of 2026-08-30T08:39:29.467469+00:00 · Report a problem