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 1.3.7 to 1.3.8

11

lib/mockModule.js

@@ -85,2 +85,3 @@ 'use strict';

mockScope.isolation = Object.assign({}, options);
return mockModule;
};

@@ -93,2 +94,3 @@

mockScope.isolation = false;
return mockModule;
};

@@ -102,2 +104,3 @@

mockScope.passBy.push(pattern);
return mockModule;
};

@@ -119,2 +122,3 @@

(0, _plugins.onEnable)((0, _mocks.getAllMocks)());
return mockModule;
};

@@ -131,2 +135,3 @@

mockModule.flush();
return mockModule;
};

@@ -150,2 +155,3 @@

if (error) throw error;
return mockModule;
};

@@ -215,3 +221,6 @@

mockModule.addPlugin = addPlugin;
mockModule.addPlugin = function (plugin) {
addPlugin(plugin);
return mockModule;
};

@@ -218,0 +227,0 @@ exports.mockModule = mockModule;

2

package.json
{
"name": "rewiremock",
"version": "1.3.7",
"version": "1.3.8",
"description": "Easy and es6 compatible dependency mocking tool.",

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

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

# Goal:
- give ability to mock everything
- give ability to do correctly.
I have wrote some articles about these ideas - https://medium.com/tag/rewiremock/latest
# API

@@ -36,9 +42,11 @@ see d.ts file, or JSDoc in javascript sources.

## mocking API
- rewiremock(moduleName: string):rewiremock - set name of overloading module
- .with(stubs: function | Object) - overloads current module
- rewiremock(moduleName: string) - set name of overloading module
- .enable/disable() - to enable or disable mock (enabled by default).
- .with(stubs: function | Object) - overloads module with a value
- .withDefault(stub: function | Object) - overload `default` es6 export
- .by(otherModule: string) - overload everything by another module
- .callThought() - first load original module, and next extend it by provided stub.
- .enable/disable() - to enable or disable mock (enabled by default).
- .toBeUsed() - enables usage checking
- .by(otherModule: string) - overload by another module
- .callThought() - first load original module, and next extend it by provided stub.
- .toBeUsed() - enables usage checking.
- .directChildOnly - will do mock only direct dependencies.
- .calledFromMock - will do mock only dependencies of mocked dependencies.
## isolation API

@@ -82,2 +90,7 @@ - rewiremock.isolation() - enables isolation

})
// secure yourself and from 'unexpected' mocks
rewiremock('myDep')
.with(mockedDep)
.calledFromMock()
```

@@ -84,0 +97,0 @@

@@ -7,3 +7,2 @@ interface OverloadedModule {

}
;

@@ -69,4 +68,4 @@ interface ModuleMock {

enable();
disable();
enable(): rewiremock;
disable(): rewiremock;

@@ -79,3 +78,3 @@ /**

around<T>(loader: () => T, creator?: Function): Promise<T>;
inScope(callback);
inScope(callback): rewiremock;

@@ -94,3 +93,3 @@ flush();

*/
isolation(options?: Object);
isolation(options?: Object): rewiremock;

@@ -100,3 +99,3 @@ /**

*/
withoutIsolation();
withoutIsolation(): rewiremock;

@@ -106,3 +105,9 @@ /**

*/
passBy(pattern: any);
passBy(pattern: any): rewiremock;
/**
* Adds a plugin
*/
addPlugin(plugin: any): rewiremock;
}

@@ -112,3 +117,3 @@

var p: rewiremock;
export = p;
export default p;
}

@@ -60,2 +60,3 @@ import Module from 'module';

mockScope.isolation = { ...options };
return mockModule;
};

@@ -68,2 +69,3 @@

mockScope.isolation = false;
return mockModule;
};

@@ -77,2 +79,3 @@

mockScope.passBy.push(pattern);
return mockModule;
};

@@ -95,2 +98,3 @@

onEnable(getAllMocks());
return mockModule;
};

@@ -107,2 +111,3 @@

mockModule.flush();
return mockModule;
};

@@ -126,2 +131,3 @@

if(error) throw error;
return mockModule;
};

@@ -192,3 +198,6 @@

mockModule.addPlugin = addPlugin;
mockModule.addPlugin = (plugin) => {
addPlugin(plugin);
return mockModule;
};

@@ -195,0 +204,0 @@ export {

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