proxyquire-universal

Proxyquire in Node and Proxyquireify in the browser with no code changes

MIT 13 个版本
安装
npm install proxyquire-universal
yarn add proxyquire-universal
pnpm add proxyquire-universal
bun add proxyquire-universal
README

proxyquire-universal tests

Browserify plugin that allows you to replace proxyquire with proxyquireify without code changes. If you only need to run your tests in a browser, just use proxyquireify directly. Make sure you're not using proxyquire features that don't have proxyquireify counterparts.

Installing

$ npm install --save-dev proxyquire-universal proxyquire proxyquireify

proxyquire-universal sets proxyquire and proxyquireify as peer dependencies so all three packages will be siblings in your node_modules folder. You have full control over which versions are used.

Usage

Write your tests for Node:

var proxyquire = require('proxyquire');
proxyquire('./a', stubs);

Then add the 'proxyquire-universal' plugin when you build your test bundle for the browser:

browserify()
  .plugin('proxyquire-universal')
  .bundle()
  .pipe(fs.createWriteStream('test-bundle.js'));

proxyquire-universal takes care of calling bundle.plugin(proxyquireify.plugin) automatically. You should not register proxyquireify manually.

Unsupported Proxyquire Features

proxyquireify has a very similar API to proxyquire and will be a perfect drop-in replacement for most use cases. However, there are certain proxyquire features that are not available in proxyquireify:

If you discover a case where proxyquire and proxyquireify behave differently, please open an issue with relevant code.

License

MIT © Ben Drucker

版本列表
3.0.2 2026-07-08
3.0.1 2020-10-29
3.0.0 2020-10-29
2.1.0 2018-11-26
2.0.0 2018-11-14
1.0.8 2015-08-05
1.0.7 2015-06-05
1.0.5 2015-05-01
1.0.4 2015-04-17
1.0.3 2015-01-11
1.0.2 2014-11-25
1.0.1 2014-10-21
1.0.0 2014-10-20