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.8.0 to 3.9.0

34

es/executor.js

@@ -55,13 +55,18 @@ 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; };

var test = function test(fileName) {
return !isolation.noAutoPassBy && mockedModules[fileName] || // parent was mocked
passBy.filter(patternMatch(fileName)).length // parent is in pass list
;
return (
// parent was mocked
!isolation.noAutoPassBy && mockedModules[fileName] ||
// parent is in pass list
passBy.filter(patternMatch(fileName)).length
);
};
while (m) {
if (test(fileName)) {
return true;
if (!isolation.noParentPassBy) {
while (m && !moduleCompare(m, parentModule)) {
if (test(fileName)) {
return true;
}
fileName = getModuleName(m);
m = getModuleParent(m);
}
fileName = getModuleName(m);
m = getModuleParent(m);
}

@@ -164,2 +169,11 @@ return test(fileName);

function tryOr(fn, failBack) {
try {
return fn();
} catch (e) {
// probably file not found
}
return failBack;
}
function mockLoader(request, parent, isMain) {

@@ -173,3 +187,5 @@ var _getScope2 = getScope(),

var baseRequest = Module._resolveFilename(request, parent);
var baseRequest = tryOr(function () {
return Module._resolveFilename(request, parent);
}, request);
var shortRequest = monkeyPatchPath(relative(getModuleName(parent), request));

@@ -176,0 +192,0 @@

@@ -72,3 +72,4 @@ var _this = this;

* @param {Object} [options]
* @param {Boolean} [options.noAutoPassBy] includes mocked modules to a isolation scope. Usage with mock.callThrough.
* @param {Boolean} [options.noAutoPassBy] excludes mocked modules to a isolation scope. Use it with mock.callThrough.
* @param {Boolean} [options.noParentPassBy] disable allowing any module, with allowed parent
*/

@@ -75,0 +76,0 @@ mockModule.isolation = function () {

@@ -75,12 +75,16 @@ 'use strict';

const test = fileName => !isolation.noAutoPassBy && mockedModules[fileName] || // parent was mocked
passBy.filter(patternMatch(fileName)).length // parent is in pass list
;
const test = fileName =>
// parent was mocked
!isolation.noAutoPassBy && mockedModules[fileName] ||
// parent is in pass list
passBy.filter(patternMatch(fileName)).length;
while (m) {
if (test(fileName)) {
return true;
if (!isolation.noParentPassBy) {
while (m && !(0, _module.moduleCompare)(m, parentModule)) {
if (test(fileName)) {
return true;
}
fileName = (0, _module.getModuleName)(m);
m = (0, _module.getModuleParent)(m);
}
fileName = (0, _module.getModuleName)(m);
m = (0, _module.getModuleParent)(m);
}

@@ -169,2 +173,11 @@ return test(fileName);

function tryOr(fn, failBack) {
try {
return fn();
} catch (e) {
// probably file not found
}
return failBack;
}
function mockLoader(request, parent, isMain) {

@@ -179,3 +192,3 @@ const {

const baseRequest = _module2.default._resolveFilename(request, parent);
const baseRequest = tryOr(() => _module2.default._resolveFilename(request, parent), request);
const shortRequest = monkeyPatchPath((0, _path.relative)((0, _module.getModuleName)(parent), request));

@@ -182,0 +195,0 @@

@@ -89,3 +89,4 @@ 'use strict';

* @param {Object} [options]
* @param {Boolean} [options.noAutoPassBy] includes mocked modules to a isolation scope. Usage with mock.callThrough.
* @param {Boolean} [options.noAutoPassBy] excludes mocked modules to a isolation scope. Use it with mock.callThrough.
* @param {Boolean} [options.noParentPassBy] disable allowing any module, with allowed parent
*/

@@ -92,0 +93,0 @@ mockModule.isolation = (options = {}) => {

{
"name": "rewiremock",
"version": "3.8.0",
"version": "3.9.0",
"description": "Advanced dependency mocking device.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -212,5 +212,6 @@ declare module 'rewiremock' {

* Activates module isolation
* @param {Boolean} [options.noAutoPassBy] auto-includes mocked modules passBy list.
* @param {Boolean} [options.noAutoPassBy] excludes mocked modules to a isolation scope. Use it with mock.callThrough.
* @param {Boolean} [options.noParentPassBy] disable allowing any module, with allowed parent
*/
isolation(options?: Object): rewiremock;
isolation(options?: { noAutoPassBy?: boolean, noParentPassBy?: boolean}): rewiremock;

@@ -217,0 +218,0 @@ /**

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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