rewiremock
Advanced tools
Comparing version 3.5.2 to 3.5.3
@@ -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; |
@@ -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; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
153841
69
3299
563
7
27
+ Addednode-libs-browser@^2.1.0
+ Addedasn1.js@4.10.1(transitive)
+ Addedassert@1.5.1(transitive)
+ Addedbase64-js@1.5.1(transitive)
+ Addedbn.js@4.12.15.2.1(transitive)
+ Addedbrorand@1.1.0(transitive)
+ Addedbrowserify-aes@1.2.0(transitive)
+ Addedbrowserify-cipher@1.0.1(transitive)
+ Addedbrowserify-des@1.0.2(transitive)
+ Addedbrowserify-rsa@4.1.1(transitive)
+ Addedbrowserify-sign@4.2.3(transitive)
+ Addedbrowserify-zlib@0.2.0(transitive)
+ Addedbuffer@4.9.2(transitive)
+ Addedbuffer-xor@1.0.3(transitive)
+ Addedbuiltin-status-codes@3.0.0(transitive)
+ Addedcall-bind@1.0.7(transitive)
+ Addedcipher-base@1.0.5(transitive)
+ Addedconsole-browserify@1.2.0(transitive)
+ Addedconstants-browserify@1.0.0(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addedcreate-ecdh@4.0.4(transitive)
+ Addedcreate-hash@1.2.0(transitive)
+ Addedcreate-hmac@1.1.7(transitive)
+ Addedcrypto-browserify@3.12.1(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addeddefine-properties@1.2.1(transitive)
+ Addeddes.js@1.1.0(transitive)
+ Addeddiffie-hellman@5.0.3(transitive)
+ Addeddomain-browser@1.2.0(transitive)
+ Addedelliptic@6.6.1(transitive)
+ Addedes-define-property@1.0.0(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedevents@3.3.0(transitive)
+ Addedevp_bytestokey@1.0.3(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.4(transitive)
+ Addedgopd@1.0.1(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-proto@1.0.3(transitive)
+ Addedhas-symbols@1.0.3(transitive)
+ Addedhash-base@3.0.5(transitive)
+ Addedhash.js@1.1.7(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedhmac-drbg@1.0.1(transitive)
+ Addedhttps-browserify@1.0.0(transitive)
+ Addedieee754@1.2.1(transitive)
+ Addedinherits@2.0.32.0.4(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedmd5.js@1.3.5(transitive)
+ Addedmiller-rabin@4.0.1(transitive)
+ Addedminimalistic-assert@1.0.1(transitive)
+ Addedminimalistic-crypto-utils@1.0.1(transitive)
+ Addednode-libs-browser@2.2.1(transitive)
+ Addedobject-inspect@1.13.3(transitive)
+ Addedobject-keys@1.1.1(transitive)
+ Addedobject.assign@4.1.5(transitive)
+ Addedos-browserify@0.3.0(transitive)
+ Addedpako@1.0.11(transitive)
+ Addedparse-asn1@5.1.7(transitive)
+ Addedpath-browserify@0.0.1(transitive)
+ Addedpbkdf2@3.1.2(transitive)
+ Addedprocess@0.11.10(transitive)
+ Addedprocess-nextick-args@2.0.1(transitive)
+ Addedpublic-encrypt@4.0.3(transitive)
+ Addedpunycode@1.4.1(transitive)
+ Addedqs@6.13.1(transitive)
+ Addedquerystring-es3@0.2.1(transitive)
+ Addedrandombytes@2.1.0(transitive)
+ Addedrandomfill@1.0.4(transitive)
+ Addedreadable-stream@2.3.8(transitive)
+ Addedripemd160@2.0.2(transitive)
+ Addedsafe-buffer@5.1.25.2.1(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedsetimmediate@1.0.5(transitive)
+ Addedsha.js@2.4.11(transitive)
+ Addedside-channel@1.0.6(transitive)
+ Addedstream-browserify@2.0.2(transitive)
+ Addedstream-http@2.8.3(transitive)
+ Addedstring_decoder@1.1.11.3.0(transitive)
+ Addedtimers-browserify@2.0.12(transitive)
+ Addedto-arraybuffer@1.0.1(transitive)
+ Addedtty-browserify@0.0.0(transitive)
+ Addedurl@0.11.4(transitive)
+ Addedutil@0.10.40.11.1(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addedvm-browserify@1.1.2(transitive)
+ Addedxtend@4.0.2(transitive)
Updatedwipe-webpack-cache@^1.0.2