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.9 to 2.0.0

8

_tests/es6.spec.js

@@ -62,6 +62,6 @@ import {expect} from 'chai';

it('should fail with callThought: ', () => {
it('should fail with callThrough: ', () => {
addPlugin(relativePlugin);
rewiremock('./foo')
.callThought()
.callThrough()
.with(()=>'aa');

@@ -88,6 +88,6 @@

it('should fail with callThought: ', () => {
it('should fail with callThrough: ', () => {
addPlugin(relativePlugin);
rewiremock('./foo')
.callThought()
.callThrough()
.withDefault(()=>'aa');

@@ -94,0 +94,0 @@

@@ -88,3 +88,3 @@ import {expect} from 'chai';

rewiremock('./lib/c/bar')
.callThought();
.callThrough();

@@ -105,3 +105,3 @@ rewiremock.enable();

rewiremock('./lib/c/bar')
.callThought();
.callThrough();

@@ -108,0 +108,0 @@ rewiremock.enable();

@@ -137,3 +137,3 @@ import {expect} from 'chai';

rewiremock('./foo')
.callThought()
.callThrough()
.by(({original}) => {

@@ -181,3 +181,3 @@ return () => "~" + original() + '~'

it('should mock all due to callthought mocked : ', () => {
it('should mock all due to callThrough mocked : ', () => {
return rewiremock.around(() => require('./lib/c/barbaz.js'),

@@ -190,3 +190,3 @@ () => {

rewiremock('./bar')
.callThought();
.callThrough();
})

@@ -193,0 +193,0 @@ .then(mocked => expect(mocked()).to.be.equal('>+mockmock'));

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

if (mock.allowCallThought) {
if (mock.allowCallThrough) {
if (!mock.original) {

@@ -114,3 +114,3 @@ mock.original = originalLoader(request, parent, isMain);

if (mock.allowCallThought) {
if (mock.allowCallThrough) {
if (typeof mock.original === 'function') {

@@ -120,3 +120,3 @@ if (_typeof(mock.value) === 'object' && Object.keys(mock.value).length === 0) {

} else {
throw new Error('rewiremock: trying to merge Functional base with CallThought mock at ' + request + '. Use overrideBy instead.');
throw new Error('rewiremock: trying to merge Functional base with callThrough mock at ' + request + '. Use overrideBy instead.');
}

@@ -123,0 +123,0 @@ }

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

* Enabled call thought original module
* @name ModuleMock.callThought
* @name ModuleMock.callThrough
* @return {ModuleMock}

@@ -38,5 +38,5 @@ */

_createClass(ModuleMock, [{
key: 'callThought',
value: function callThought() {
this.mock.allowCallThought = true;
key: 'callThrough',
value: function callThrough() {
this.mock.allowCallThrough = true;
return this;

@@ -43,0 +43,0 @@ }

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

* @param {Object} [options]
* @param {Boolean} [options.noAutoPassBy] includes mocked modules to a isolation scope. Usage with mock.callThought.
* @param {Boolean} [options.noAutoPassBy] includes mocked modules to a isolation scope. Usage with mock.callThrough.
*/

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

{
"name": "rewiremock",
"version": "1.3.9",
"version": "2.0.0",
"description": "Easy and es6 compatible dependency mocking tool.",

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

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

- .by(otherModule: string) - overload by another module
- .callThought() - first load original module, and next extend it by provided stub.
- .callThrough() - first load original module, and next extend it by provided stub.
- .toBeUsed() - enables usage checking.

@@ -85,3 +85,3 @@ - .directChildOnly - will do mock only direct dependencies.

rewiremock('someLibrary')
.callThought()
.callThrough()
.with({

@@ -88,0 +88,0 @@ onlyOneMethod

@@ -12,3 +12,3 @@ interface OverloadedModule {

*/
callThought(): ModuleMock,
callThrough(): ModuleMock,

@@ -89,3 +89,3 @@ /**

* Activates module isolation
* @param {Boolean} [options.noAutoPassBy] includes mocked modules to a isolation scope. Usage with mock.callThought.
* @param {Boolean} [options.noAutoPassBy] auto-includes mocked modules passBy list.
*/

@@ -92,0 +92,0 @@ isolation(options?: Object): rewiremock;

@@ -74,3 +74,3 @@ import Module from 'module';

if (mock.allowCallThought) {
if (mock.allowCallThrough) {
if (!mock.original) {

@@ -97,3 +97,3 @@ mock.original = originalLoader(request, parent, isMain);

if (mock.allowCallThought) {
if (mock.allowCallThrough) {
if(typeof(mock.original) === 'function') {

@@ -106,3 +106,3 @@ if (

} else {
throw new Error('rewiremock: trying to merge Functional base with CallThought mock at '
throw new Error('rewiremock: trying to merge Functional base with callThrough mock at '
+ request + '. Use overrideBy instead.');

@@ -109,0 +109,0 @@ }

@@ -12,7 +12,7 @@ import {convertName} from './plugins';

* Enabled call thought original module
* @name ModuleMock.callThought
* @name ModuleMock.callThrough
* @return {ModuleMock}
*/
callThought() {
this.mock.allowCallThought = true;
callThrough() {
this.mock.allowCallThrough = true;
return this;

@@ -19,0 +19,0 @@ }

@@ -56,3 +56,3 @@ import Module from 'module';

* @param {Object} [options]
* @param {Boolean} [options.noAutoPassBy] includes mocked modules to a isolation scope. Usage with mock.callThought.
* @param {Boolean} [options.noAutoPassBy] includes mocked modules to a isolation scope. Usage with mock.callThrough.
*/

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

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