🚀 Socket Launch Week 🚀 Day 3: Socket Acquires Coana.Learn More
Socket
Sign inDemoInstall
Socket

sinon

Package Overview
Dependencies
Maintainers
4
Versions
212
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sinon - npm Package Compare versions

Comparing version

to
15.0.3

lib/package.json

3

lib/sinon.js

@@ -7,3 +7,2 @@ "use strict";

var fakeTimers = require("./sinon/util/fake-timers");
var format = require("./sinon/util/core/format");
var nise = require("nise");

@@ -23,4 +22,2 @@ var Sandbox = require("./sinon/sandbox");

setFormatter: format.setFormatter,
// fake timers

@@ -27,0 +24,0 @@ timers: fakeTimers.timers,

@@ -8,3 +8,3 @@ "use strict";

var timesInWords = require("./util/core/times-in-words");
var format = require("./util/core/format");
var inspect = require("util").inspect;
var stringSlice = require("@sinonjs/commons").prototypes.string.slice;

@@ -163,6 +163,12 @@ var globalObject = require("@sinonjs/commons").global;

if (method.callCount !== count) {
var msg = `expected %n to be called ${timesInWords(
count
)} but was called %c%C`;
var msg;
if (typeof count !== "number") {
msg =
`expected ${inspect(count)} to be a number ` +
`but was of type ${typeof count}`;
failAssertion(this, msg);
} else if (method.callCount !== count) {
msg =
`expected %n to be called ${timesInWords(count)} ` +
`but was called %c%C`;
failAssertion(this, method.printf(msg));

@@ -205,4 +211,4 @@ } else {

"expected value to match",
` expected = ${format(expectation)}`,
` actual = ${format(actual)}`,
` expected = ${inspect(expectation)}`,
` actual = ${inspect(actual)}`,
];

@@ -209,0 +215,0 @@

@@ -34,2 +34,4 @@ "use strict";

fake.fakeFn = fn;
fake.exception = undefined;
fake.exceptionCreator = undefined;
},

@@ -273,2 +275,3 @@

enumerable: true,
writable: true,
configurable:

@@ -275,0 +278,0 @@ rootStub.shadowsPropOnPrototype ||

@@ -12,3 +12,3 @@ "use strict";

var deepEqual = require("@sinonjs/samsam").deepEqual;
var format = require("./util/core/format");
var inspect = require("util").inspect;
var valueToString = require("@sinonjs/commons").valueToString;

@@ -170,3 +170,3 @@

mockExpectation.fail(
`${this.method} received no arguments, expected ${format(
`${this.method} received no arguments, expected ${inspect(
expectedArguments

@@ -179,5 +179,5 @@ )}`

mockExpectation.fail(
`${this.method} received too few arguments (${format(
`${this.method} received too few arguments (${inspect(
args
)}), expected ${format(expectedArguments)}`
)}), expected ${inspect(expectedArguments)}`
);

@@ -191,5 +191,5 @@ }

mockExpectation.fail(
`${this.method} received too many arguments (${format(
`${this.method} received too many arguments (${inspect(
args
)}), expected ${format(expectedArguments)}`
)}), expected ${inspect(expectedArguments)}`
);

@@ -203,3 +203,3 @@ }

mockExpectation.fail(
`${this.method} received wrong arguments ${format(
`${this.method} received wrong arguments ${inspect(
args

@@ -212,5 +212,5 @@ )}, didn't match ${String(expectedArguments)}`

mockExpectation.fail(
`${this.method} received wrong arguments ${format(
`${this.method} received wrong arguments ${inspect(
args
)}, expected ${format(expectedArguments)}`
)}, expected ${inspect(expectedArguments)}`
);

@@ -217,0 +217,0 @@ }

@@ -11,3 +11,3 @@ "use strict";

/**
* Returns a fake for a given function or undefined. If no functino is given, a
* Returns a fake for a given function or undefined. If no function is given, a
* new fake is returned. If the given function is already a fake, it is

@@ -14,0 +14,0 @@ * returned as is. Otherwise the given function is wrapped in a new fake.

@@ -7,3 +7,3 @@ "use strict";

var functionName = require("@sinonjs/commons").functionName;
var sinonFormat = require("./util/core/format");
var inspect = require("util").inspect;
var valueToString = require("@sinonjs/commons").valueToString;

@@ -18,2 +18,7 @@

/**
* @param proxy
* @param text
* @param args
*/
function throwYieldError(proxy, text, args) {

@@ -208,3 +213,3 @@ var msg = functionName(proxy) + text;

formattedArgs = map(this.args, function (arg) {
return sinonFormat(arg);
return inspect(arg);
});

@@ -215,3 +220,3 @@

if (typeof this.returnValue !== "undefined") {
callStr += ` => ${sinonFormat(this.returnValue)}`;
callStr += ` => ${inspect(this.returnValue)}`;
}

@@ -227,3 +232,4 @@

if (this.stack) {
// Omit the error message and the two top stack frames in sinon itself:
// If we have a stack, add the first frame that's in end-user code
// Skip the first two frames because they will refer to Sinon code
callStr += (this.stack.split("\n")[3] || "unknown").replace(

@@ -257,2 +263,11 @@ /^\s*(?:at\s+|@)?/,

/**
* @param proxy
* @param thisValue
* @param args
* @param returnValue
* @param exception
* @param id
* @param errorWithCallStack
*/
function createProxyCall(

@@ -259,0 +274,0 @@ proxy,

@@ -9,3 +9,3 @@ "use strict";

var proxyInvoke = require("./proxy-invoke");
var sinonFormat = require("./util/core/format");
var inspect = require("util").inspect;

@@ -124,12 +124,12 @@ var push = arrayProto.push;

return (format || "").replace(/%(.)/g, function (match, specifyer) {
formatter = proxyApi.formatters[specifyer];
return (format || "").replace(/%(.)/g, function (match, specifier) {
formatter = proxyApi.formatters[specifier];
if (typeof formatter === "function") {
return String(formatter(spyInstance, args));
} else if (!isNaN(parseInt(specifyer, 10))) {
return sinonFormat(args[specifyer - 1]);
} else if (!isNaN(parseInt(specifier, 10))) {
return inspect(args[specifier - 1]);
}
return `%${specifyer}`;
return `%${specifier}`;
});

@@ -136,0 +136,0 @@ },

@@ -14,2 +14,3 @@ "use strict";

var sinonStub = require("./stub");
var sinonCreateStubInstance = require("./create-stub-instance");
var sinonFake = require("./fake");

@@ -75,3 +76,3 @@ var valueToString = require("@sinonjs/commons").valueToString;

sandbox.createStubInstance = function createStubInstance() {
var stubbed = sinonStub.createStubInstance.apply(null, arguments);
var stubbed = sinonCreateStubInstance.apply(null, arguments);

@@ -78,0 +79,0 @@ var ownMethods = collectOwnMethods(stubbed);

@@ -7,3 +7,3 @@ "use strict";

var timesInWords = require("./util/core/times-in-words");
var sinonFormat = require("./util/core/format");
var inspect = require("util").inspect;
var jsDiff = require("diff");

@@ -18,4 +18,5 @@

var calledArgumentMessage = calledArgMessage;
var matcherMessage = matcher.message;
if (!matcher.test(calledArg)) {
matcher.message = color.red(matcher.message);
matcherMessage = color.red(matcher.message);
if (calledArgumentMessage) {

@@ -25,3 +26,3 @@ calledArgumentMessage = color.green(calledArgumentMessage);

}
return `${calledArgumentMessage} ${matcher.message}`;
return `${calledArgumentMessage} ${matcherMessage}`;
}

@@ -78,8 +79,10 @@

) {
if (calledArgs[j]) {
calledArgs[j] = quoteStringValue(calledArgs[j]);
var calledArg = calledArgs[j];
var expectedArg = expectedArgs[j];
if (calledArg) {
calledArg = quoteStringValue(calledArg);
}
if (expectedArgs[j]) {
expectedArgs[j] = quoteStringValue(expectedArgs[j]);
if (expectedArg) {
expectedArg = quoteStringValue(expectedArg);
}

@@ -90,7 +93,7 @@

var calledArgMessage =
j < calledArgs.length ? sinonFormat(calledArgs[j]) : "";
if (match.isMatcher(expectedArgs[j])) {
j < calledArgs.length ? inspect(calledArg) : "";
if (match.isMatcher(expectedArg)) {
message += colorSinonMatchText(
expectedArgs[j],
calledArgs[j],
expectedArg,
calledArg,
calledArgMessage

@@ -100,5 +103,3 @@ );

var expectedArgMessage =
j < expectedArgs.length
? sinonFormat(expectedArgs[j])
: "";
j < expectedArgs.length ? inspect(expectedArg) : "";
var diff = jsDiff.diffJson(

@@ -135,3 +136,3 @@ calledArgMessage,

for (var i = 0, l = spyInstance.callCount; i < l; ++i) {
push(objects, sinonFormat(spyInstance.thisValues[i]));
push(objects, inspect(spyInstance.thisValues[i]));
}

@@ -145,3 +146,3 @@

map(args, function (arg) {
return sinonFormat(arg);
return inspect(arg);
}),

@@ -148,0 +149,0 @@ ", "

@@ -15,2 +15,3 @@ "use strict";

var isEsModule = require("./util/core/is-es-module");
var sinonType = require("./util/core/sinon-type");
var wrapMethod = require("./util/core/wrap-method");

@@ -62,2 +63,4 @@ var throwOnFalsyObject = require("./throw-on-falsy-object");

sinonType.set(proxy, "stub");
return proxy;

@@ -86,2 +89,5 @@ }

var actualDescriptor = getPropertyDescriptor(object, property);
assertValidPropertyDescriptor(actualDescriptor, property);
var isObjectOrFunction =

@@ -129,26 +135,32 @@ typeof object === "object" || typeof object === "function";

stub.createStubInstance = function (constructor, overrides) {
if (typeof constructor !== "function") {
throw new TypeError("The constructor should be a function.");
function assertValidPropertyDescriptor(descriptor, property) {
if (!descriptor || !property) {
return;
}
if (!descriptor.configurable && !descriptor.writable) {
throw new TypeError(
`Descriptor for property ${property} is non-configurable and non-writable`
);
}
if ((descriptor.get || descriptor.set) && !descriptor.configurable) {
throw new TypeError(
`Descriptor for accessor property ${property} is non-configurable`
);
}
if (isDataDescriptor(descriptor) && !descriptor.writable) {
throw new TypeError(
`Descriptor for data property ${property} is non-writable`
);
}
}
var stubbedObject = stub(Object.create(constructor.prototype));
function isDataDescriptor(descriptor) {
return (
!descriptor.value &&
!descriptor.writable &&
!descriptor.set &&
!descriptor.get
);
}
forEach(Object.keys(overrides || {}), function (propertyName) {
if (propertyName in stubbedObject) {
var value = overrides[propertyName];
if (value && value.createStubInstance) {
stubbedObject[propertyName] = value;
} else {
stubbedObject[propertyName].returns(value);
}
} else {
throw new Error(
`Cannot stub ${propertyName}. Property does not exist!`
);
}
});
return stubbedObject;
};
/*eslint-disable no-use-before-define*/

@@ -155,0 +167,0 @@ function getParentBehaviour(stubInstance) {

@@ -111,3 +111,3 @@ "use strict";

if the sorce has an Accessor property copy over the accessor functions (get and set)
data properties has writable attribute where as acessor property don't
data properties has writable attribute where as accessor property don't
REF: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#properties

@@ -114,0 +114,0 @@ */

@@ -8,5 +8,13 @@ "use strict";

function walkObject(predicate, object, filter) {
/**
* A utility that allows traversing an object, applying mutating functions on the properties
*
* @param {Function} mutator called on each property
* @param {object} object the object we are walking over
* @param {Function} filter a predicate (boolean function) that will decide whether or not to apply the mutator to the current property
* @returns {void} nothing
*/
function walkObject(mutator, object, filter) {
var called = false;
var name = functionName(predicate);
var name = functionName(mutator);

@@ -30,7 +38,7 @@ if (!object) {

called = true;
predicate(object, prop);
mutator(object, prop);
}
} else {
called = true;
predicate(object, prop);
mutator(object, prop);
}

@@ -41,3 +49,5 @@ }

if (!called) {
throw new Error(`Expected to ${name} methods on object but found none`);
throw new Error(
`Found no methods on object to which we could apply mutations`
);
}

@@ -44,0 +54,0 @@

"use strict";
// eslint-disable-next-line no-empty-function
const noop = () => {};
var getPropertyDescriptor = require("./get-property-descriptor");
var extend = require("./extend");
const sinonType = require("./sinon-type");
var hasOwnProperty =

@@ -233,2 +236,7 @@ require("@sinonjs/commons").prototypes.object.hasOwnProperty;

}
if (sinonType.get(object) === "stub-instance") {
// this is simply to avoid errors after restoring if something should
// traverse the object in a cleanup phase, ref #2477
object[property] = noop;
}
}

@@ -235,0 +243,0 @@

@@ -18,3 +18,3 @@ {

],
"version": "11.1.2",
"version": "15.0.3",
"homepage": "https://sinonjs.org/",

@@ -41,15 +41,16 @@ "author": "Christian Johansen",

"test-webworker": "mochify --no-detect-globals --https-server 8080 --no-request-interception test/webworker/webworker-support-assessment.js",
"test-esm": "mocha -r esm test/es2015/module-support-assessment-test.es6",
"test-esm-bundle": "node test/es2015/check-esm-bundle-is-runnable.js",
"test-esm-support": "mocha test/es2015/module-support-assessment-test.mjs",
"check-esm-bundle-runs-in-browser": "node test/es2015/check-esm-bundle-is-runnable.js",
"test-docker-image": "docker-compose up",
"test-runnable-examples": "docs/release-source/release/examples/run-test.sh",
"test": "npm run test-node && npm run test-headless && npm run test-webworker && npm run test-esm",
"test": "npm run test-node && npm run test-headless && npm run test-webworker",
"check-dependencies": "dependency-check package.json --no-dev --ignore-module esm",
"build": "node ./build.js",
"build": "node ./build.cjs",
"build-docs": "cd docs; bundle exec jekyll build",
"serve-docs": "cd docs; bundle exec jekyll serve --incremental --verbose",
"lint": "eslint '**/*.{js,mjs}'",
"lint": "eslint '**/*.{js,cjs,mjs}'",
"unimported": "unimported .",
"pretest-webworker": "npm run build",
"prebuild": "rimraf pkg && npm run check-dependencies",
"postbuild": "npm run test-esm-bundle",
"postbuild": "npm run test-esm-support && npm run check-esm-bundle-runs-in-browser",
"prebuild-docs": "./scripts/update-compatibility.js",

@@ -60,2 +61,3 @@ "prepublishOnly": "npm run build",

"preversion": "./scripts/preversion.sh",
"version": "./scripts/version.sh",
"postversion": "./scripts/postversion.sh"

@@ -77,32 +79,34 @@ },

"dependencies": {
"@sinonjs/commons": "^1.8.3",
"@sinonjs/fake-timers": "^7.1.2",
"@sinonjs/samsam": "^6.0.2",
"diff": "^5.0.0",
"nise": "^5.1.0",
"@sinonjs/commons": "^3.0.0",
"@sinonjs/fake-timers": "^10.0.2",
"@sinonjs/samsam": "^8.0.0",
"diff": "^5.1.0",
"nise": "^5.1.4",
"supports-color": "^7.2.0"
},
"devDependencies": {
"@babel/core": "^7.14.3",
"@sinonjs/eslint-config": "^4.0.2",
"@babel/core": "^7.21.0",
"@sinonjs/eslint-config": "^4.0.6",
"@sinonjs/eslint-plugin-no-prototype-methods": "^0.1.1",
"@sinonjs/referee": "^8.0.2",
"babel-plugin-istanbul": "^6.0.0",
"@sinonjs/referee": "^10.0.0",
"@studio/changes": "^2.2.0",
"babel-plugin-istanbul": "^6.1.1",
"babelify": "^10.0.0",
"browserify": "^16.5.2",
"debug": "^4.3.1",
"debug": "^4.3.4",
"dependency-check": "^4.1.0",
"esm": "^3.2.25",
"husky": "^6.0.0",
"lint-staged": "^11.0.0",
"mocha": "^8.4.0",
"mochify": "^7.1.1",
"lint-staged": "^13.2.0",
"mocha": "^10.2.0",
"mochify": "^9.2.0",
"nyc": "^15.1.0",
"prettier": "^2.3.0",
"prettier": "^2.8.4",
"proxyquire": "^2.1.3",
"proxyquire-universal": "^3.0.1",
"proxyquireify": "^3.2.1",
"puppeteer": "^9.1.1",
"rimraf": "^3.0.2",
"shelljs": "^0.8.4"
"puppeteer": "^19.7.4",
"rimraf": "^4.4.0",
"semver": "^7.3.8",
"shelljs": "^0.8.5",
"unimported": "^1.26.0"
},

@@ -122,2 +126,10 @@ "files": [

"module": "./pkg/sinon-esm.js",
"exports": {
".": {
"require": "./lib/sinon.js",
"import": "./pkg/sinon-esm.js"
},
"./*": "./*"
},
"type": "module",
"cdn": "./pkg/sinon.js",

@@ -124,0 +136,0 @@ "jsdelivr": "./pkg/sinon.js",

@@ -15,4 +15,2 @@ <h1 align=center>

<a href="https://www.npmjs.com/package/sinon"><img src="https://img.shields.io/npm/v/sinon.svg?style=flat" alt="npm version"></a>
<a href="https://gitter.im/sinonjs/sinon?utm_source=badge&amp;utm_medium=badge&amp;utm_campaign=pr-badge&amp;utm_content=badge"><img src="https://badges.gitter.im/Join%20Chat.svg" alt="Join the chat at https://gitter.im/sinonjs/sinon"></a>
<a href="http://travis-ci.org/sinonjs/sinon"><img src="https://secure.travis-ci.org/sinonjs/sinon.svg?branch=master" alt="Build status"></a>
<a href="https://saucelabs.com/u/sinonjs"><img src="https://saucelabs.com/buildstatus/sinonjs" alt="Sauce Test Status"/></a>

@@ -27,7 +25,9 @@ <a href="https://codecov.io/gh/sinonjs/sinon"><img src="https://codecov.io/gh/sinonjs/sinon/branch/master/graph/badge.svg" alt="Codecov status"></a>

<!-- Shows an outdated badge. Will not be fixed until https://github.com/sinonjs/fake-timers/pull/395 ships.
<p align=center>
<a href="https://app.saucelabs.com/u/sinonjs">
<img src="https://app.saucelabs.com/browser-matrix/sinonjs.svg" alt="Sauce Test Status"/>
</a>
</a>
</p>
-->

@@ -34,0 +34,0 @@ ## Compatibility

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display