Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rewiremock

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rewiremock - npm Package Compare versions

Comparing version 3.5.2 to 3.5.3

es/plugins/node-lib-browser.js

2

es/executor.js

@@ -158,2 +158,4 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };

//autoMock(baseRequest);
var mock = getMock(baseRequest) || getMock(request) || getMock(shortRequest);

@@ -160,0 +162,0 @@

@@ -44,4 +44,8 @@ import path from 'path';

if (typeof __webpack_require__ !== "undefined") {
addPlugin(plugins.nodeLibBrowser);
}
export { addPlugin, removePlugin, plugins };
export default API.mockModule;

2

es/mockModule.js

@@ -258,3 +258,3 @@ var _this = this;

}).filter(function (key) {
return key.indexOf('\.node') < 0;
return key.indexOf('.node') < 0;
}).forEach(function (key) {

@@ -261,0 +261,0 @@ return delete newCache[key];

@@ -145,2 +145,4 @@ import { join, resolve, isAbsolute, dirname, basename, sep } from 'path';

// notModuleRegExp from https://github.com/webpack/enhanced-resolve/blob/master/lib/Resolver.js
/* eslint-disable no-useless-escape */
var notModuleRegExp = /^\.$|^\.[\\\/]|^\.\.$|^\.\.[\/\\]|^\/|^[A-Z]:[\\\/]/i;

@@ -147,0 +149,0 @@ var isModule = !notModuleRegExp.test(aliasTo);

@@ -14,2 +14,4 @@ import childOnly from './childOnly';

import nodeLibBrowser from './node-lib-browser';
var exports = {

@@ -27,5 +29,7 @@ childOnly: childOnly,

usedByDefault: usedByDefault,
directChild: directChild
directChild: directChild,
nodeLibBrowser: nodeLibBrowser
};
export default exports;

@@ -14,3 +14,3 @@ import { getAllMocks } from './mocks';

// never wipe .node(native) module
if (moduleName.indexOf('\.node') > -1) {
if (moduleName.indexOf('.node') > -1) {
return false;

@@ -17,0 +17,0 @@ }

@@ -183,2 +183,4 @@ 'use strict';

//autoMock(baseRequest);
var mock = (0, _mocks.getMock)(baseRequest) || (0, _mocks.getMock)(request) || (0, _mocks.getMock)(shortRequest);

@@ -185,0 +187,0 @@

@@ -65,2 +65,6 @@ 'use strict';

if (typeof __webpack_require__ !== "undefined") {
addPlugin(_index2.default.nodeLibBrowser);
}
exports.addPlugin = addPlugin;

@@ -67,0 +71,0 @@ exports.removePlugin = removePlugin;

@@ -279,3 +279,3 @@ 'use strict';

}).filter(function (key) {
return key.indexOf('\.node') < 0;
return key.indexOf('.node') < 0;
}).forEach(function (key) {

@@ -282,0 +282,0 @@ return delete newCache[key];

@@ -161,2 +161,4 @@ 'use strict';

// notModuleRegExp from https://github.com/webpack/enhanced-resolve/blob/master/lib/Resolver.js
/* eslint-disable no-useless-escape */
var notModuleRegExp = /^\.$|^\.[\\\/]|^\.\.$|^\.\.[\/\\]|^\/|^[A-Z]:[\\\/]/i;

@@ -163,0 +165,0 @@ var isModule = !notModuleRegExp.test(aliasTo);

@@ -51,2 +51,6 @@ 'use strict';

var _nodeLibBrowser = require('./node-lib-browser');
var _nodeLibBrowser2 = _interopRequireDefault(_nodeLibBrowser);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -66,5 +70,7 @@

usedByDefault: _usedByDefault2.default,
directChild: _directChild2.default
directChild: _directChild2.default,
nodeLibBrowser: _nodeLibBrowser2.default
};
exports.default = _exports;

@@ -23,3 +23,3 @@ 'use strict';

// never wipe .node(native) module
if (moduleName.indexOf('\.node') > -1) {
if (moduleName.indexOf('.node') > -1) {
return false;

@@ -26,0 +26,0 @@ }

{
"name": "rewiremock",
"version": "3.5.2",
"version": "3.5.3",
"description": "Advanced dependency mocking device.",

@@ -20,3 +20,3 @@ "main": "lib/index.js",

"prepublish": "npm run build",
"lint": "eslint src tests",
"lint": "eslint src",
"lint:fix": "eslint src tests --fix"

@@ -36,3 +36,5 @@ },

"webpack",
"rewiremock.d.ts"
"rewiremock.d.ts",
"node.js",
"internal.js"
],

@@ -72,5 +74,6 @@ "keywords": [

"lodash.template": "^4.4.0",
"node-libs-browser": "^2.1.0",
"path-parse": "^1.0.5",
"wipe-node-cache": "^1.1.0",
"wipe-webpack-cache": "^1.0.0"
"wipe-webpack-cache": "^1.0.2"
},

@@ -88,3 +91,3 @@ "devDependencies": {

"chai": "^3.5.0",
"eslint": "^3.19.0",
"eslint": "^4.19.1",
"eslint-plugin-mocha": "^4.9.0",

@@ -103,5 +106,6 @@ "flow-bin": "^0.59.0",

"sinon": "^4.4.2",
"webpack": "^3.5.5",
"webpack-dev-server": "^2.7.1"
"webpack": "^4.2.0",
"webpack-cli": "^2.0.13",
"webpack-dev-server": "^3.1.1"
}
}

@@ -5,7 +5,19 @@ # rewiremock [![Build Status](https://secure.travis-ci.org/theKashey/rewiremock.svg)](http://travis-ci.org/theKashey/rewiremock)

Simple es6-friendly mocking library inspired by the best libraries:
The most powerful mocking library, inspired by the best libraries:
- [mockery](https://github.com/mfncooper/mockery) - the library I like the most. Rewiremock is a better mockery.
- [proxyquire](https://github.com/theKashey/proxyquire) - the one with quite handy API. Rewiremock do it better.
- [proxyquire](https://github.com/theKashey/proxyquire) - the one with quite handy API. Rewiremock is it a better proxyquire.
- [mock-require](https://github.com/boblauer/mock-require) - the simplest thing ever. Things must not be complex.
- [jest.mocks](https://facebook.github.io/jest/docs/en/manual-mocks.html) - may be the right way to mock. Rewiremock can do the same.
```text
/$$ /$$ /$$ /$$ /$$ /$$
| $$ /$ | $$|__/ | $$$ /$$$ | $$
/$$$$$$ /$$$$$$ | $$ /$$$| $$ /$$ /$$$$$$ /$$$$$$ | $$$$ /$$$$ /$$$$$$ /$$$$$$$| $$ /$$
/$$__ $$ /$$__ $$| $$/$$ $$ $$| $$ /$$__ $$ /$$__ $$| $$ $$/$$ $$ /$$__ $$ /$$_____/| $$ /$$/
| $$ \__/| $$$$$$$$| $$$$_ $$$$| $$| $$ \__/| $$$$$$$$| $$ $$$| $$| $$ \ $$| $$ | $$$$$$/
| $$ | $$_____/| $$$/ \ $$$| $$| $$ | $$_____/| $$\ $ | $$| $$ | $$| $$ | $$_ $$
| $$ | $$$$$$$| $$/ \ $$| $$| $$ | $$$$$$$| $$ \/ | $$| $$$$$$/| $$$$$$$| $$ \ $$
|__/ \_______/|__/ \__/|__/|__/ \_______/|__/ |__/ \______/ \_______/|__/ \__/
```
By its nature rewiremock has same behavior as Mockery. But it can behave like others too.

@@ -188,2 +200,10 @@ It covers _any_ case. It is the right way to mock your dependencies or perform dependency injection.

> PS: Just use usedByDefault to ensure module names are resolved correctly.
There is also a special entry point for node.js, with nodejs plugin activated, and rewiremock as es5 export
```js
const rewiremock = require('rewiremock/node');
// meanwhile
const rewiremock = require('rewiremock').default;
```

@@ -190,0 +210,0 @@ ## To run inside webpack enviroment.

@@ -15,2 +15,3 @@ const {dirname, resolve} = require('path');

const asIndex = keys.find(name => name.indexOf(targetFileIndex) > 0);
if (asFile && asIndex && asFile.substr(targetFile.length+1).indexOf('/') >= 0) {

@@ -17,0 +18,0 @@ return asIndex;

@@ -14,3 +14,5 @@ const {relative} = require("path");

const source = new ConcatSource();
source.add(injectString);
if (moduleSource.source().indexOf('require') > 0) {
source.add(injectString);
}
source.add(moduleSource);

@@ -17,0 +19,0 @@ return source;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc