From 11a8e3f24ccec981a280dbe63df316d1fbde4ddd Mon Sep 17 00:00:00 2001 From: Carl-Erik Kopseng Date: Fri, 20 Oct 2023 16:32:29 +0200 Subject: [PATCH] Remove Proxyquire as it did not handle newer syntax The defaults of Prettier 3 threw Proxyquirify into a frenzy. Did the minimal rewrite (DI) that worked --- lib/sinon.js | 83 ++--- lib/sinon/color.js | 46 +-- lib/sinon/spy-formatters.js | 17 +- package-lock.json | 585 ----------------------------------- package.json | 5 +- test/assert-test.js | 3 +- test/proxy-test.js | 3 +- test/sinon-test.js | 12 +- test/util/core/color-test.js | 14 +- 9 files changed, 101 insertions(+), 667 deletions(-) diff --git a/lib/sinon.js b/lib/sinon.js index 27528ed54..bb735342f 100644 --- a/lib/sinon.js +++ b/lib/sinon.js @@ -9,40 +9,53 @@ const Sandbox = require("./sinon/sandbox"); const stub = require("./sinon/stub"); const promise = require("./sinon/promise"); -const apiMethods = { - createSandbox: createSandbox, - assert: require("./sinon/assert"), - match: require("@sinonjs/samsam").createMatcher, - restoreObject: require("./sinon/restore-object"), - - expectation: require("./sinon/mock-expectation"), - defaultConfig: require("./sinon/util/core/default-config"), - - // fake timers - timers: fakeTimers.timers, - - // fake XHR - xhr: nise.fakeXhr.xhr, - FakeXMLHttpRequest: nise.fakeXhr.FakeXMLHttpRequest, - - // fake server - fakeServer: nise.fakeServer, - fakeServerWithClock: nise.fakeServerWithClock, - createFakeServer: nise.fakeServer.create.bind(nise.fakeServer), - createFakeServerWithClock: nise.fakeServerWithClock.create.bind( - nise.fakeServerWithClock, - ), - - addBehavior: function (name, fn) { - behavior.addBehavior(stub, name, fn); - }, - - // fake promise - promise: promise, -}; - -const sandbox = new Sandbox(); - -const api = extend(sandbox, apiMethods); +/** + * @param {object} opts injection point to override the default XHR lib in testing + * @param {object} opts.sinonXhrLib + * @returns {object} a configured sandbox + */ +function createApi({ sinonXhrLib }) { + const apiMethods = { + createSandbox: createSandbox, + assert: require("./sinon/assert"), + match: require("@sinonjs/samsam").createMatcher, + restoreObject: require("./sinon/restore-object"), + + expectation: require("./sinon/mock-expectation"), + defaultConfig: require("./sinon/util/core/default-config"), + + // fake timers + timers: fakeTimers.timers, + + // fake XHR + xhr: sinonXhrLib.fakeXhr.xhr, + FakeXMLHttpRequest: sinonXhrLib.fakeXhr.FakeXMLHttpRequest, + + // fake server + fakeServer: sinonXhrLib.fakeServer, + fakeServerWithClock: sinonXhrLib.fakeServerWithClock, + createFakeServer: sinonXhrLib.fakeServer.create.bind( + sinonXhrLib.fakeServer, + ), + createFakeServerWithClock: sinonXhrLib.fakeServerWithClock.create.bind( + sinonXhrLib.fakeServerWithClock, + ), + + addBehavior: function (name, fn) { + behavior.addBehavior(stub, name, fn); + }, + + // fake promise + promise: promise, + }; + + const sandbox = new Sandbox(); + return extend(sandbox, apiMethods); +} + +const api = createApi({ sinonXhrLib: nise }); module.exports = api; + +// solely exposed for easier testing +module.exports.createApi = createApi; diff --git a/lib/sinon/color.js b/lib/sinon/color.js index 9cf520ea8..6ddb1acb9 100644 --- a/lib/sinon/color.js +++ b/lib/sinon/color.js @@ -1,31 +1,35 @@ "use strict"; -const supportsColor = require("supports-color"); - -function colorize(str, color) { - if (supportsColor.stdout === false) { - return str; +module.exports = class Colorizer { + constructor(supportsColor = require("supports-color")) { + this.supportsColor = supportsColor; } - return `\x1b[${color}m${str}\x1b[0m`; -} + colorize(str, color) { + if (this.supportsColor.stdout === false) { + return str; + } -exports.red = function (str) { - return colorize(str, 31); -}; + return `\x1b[${color}m${str}\x1b[0m`; + } -exports.green = function (str) { - return colorize(str, 32); -}; + red(str) { + return this.colorize(str, 31); + } -exports.cyan = function (str) { - return colorize(str, 96); -}; + green(str) { + return this.colorize(str, 32); + } -exports.white = function (str) { - return colorize(str, 39); -}; + cyan(str) { + return this.colorize(str, 96); + } -exports.bold = function (str) { - return colorize(str, 1); + white(str) { + return this.colorize(str, 39); + } + + bold(str) { + return this.colorize(str, 1); + } }; diff --git a/lib/sinon/spy-formatters.js b/lib/sinon/spy-formatters.js index f867e0ca2..67fb12f47 100644 --- a/lib/sinon/spy-formatters.js +++ b/lib/sinon/spy-formatters.js @@ -1,7 +1,8 @@ "use strict"; const arrayProto = require("@sinonjs/commons").prototypes.array; -const color = require("./color"); +const Colorizer = require("./color"); +const color = new Colorizer(); const match = require("@sinonjs/samsam").createMatcher; const timesInWords = require("./util/core/times-in-words"); const inspect = require("util").inspect; @@ -12,6 +13,12 @@ const map = arrayProto.map; const push = arrayProto.push; const slice = arrayProto.slice; +/** + * + * @param matcher + * @param calledArg + * @param calledArgMessage + */ function colorSinonMatchText(matcher, calledArg, calledArgMessage) { let calledArgumentMessage = calledArgMessage; let matcherMessage = matcher.message; @@ -24,6 +31,10 @@ function colorSinonMatchText(matcher, calledArg, calledArgMessage) { return `${calledArgumentMessage} ${matcherMessage}`; } +/** + * + * @param diff + */ function colorDiffText(diff) { const objects = map(diff, function (part) { let text = part.value; @@ -40,6 +51,10 @@ function colorDiffText(diff) { return join(objects, ""); } +/** + * + * @param value + */ function quoteStringValue(value) { if (typeof value === "string") { return JSON.stringify(value); diff --git a/package-lock.json b/package-lock.json index 98f34e352..23c67a8c7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -32,9 +32,6 @@ "mochify": "^9.2.0", "nyc": "^15.1.0", "prettier": "^3.0.3", - "proxyquire": "^2.1.3", - "proxyquire-universal": "^3.0.1", - "proxyquireify": "^3.2.1", "puppeteer": "^21.4.0", "rimraf": "^5.0.5", "semver": "^7.5.4", @@ -2928,98 +2925,6 @@ "node": ">=0.8.0" } }, - "node_modules/escodegen": { - "version": "1.14.3", - "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.14.3.tgz", - "integrity": "sha512-qFcX0XJkdg+PB3xjZZG/wKSuT1PnQWx57+TVSjIMmILd2yC/6ByYElPwJnslDsuWuSAp4AwJGumarAAmJch5Kw==", - "dev": true, - "dependencies": { - "esprima": "^4.0.1", - "estraverse": "^4.2.0", - "esutils": "^2.0.2", - "optionator": "^0.8.1" - }, - "bin": { - "escodegen": "bin/escodegen.js", - "esgenerate": "bin/esgenerate.js" - }, - "engines": { - "node": ">=4.0" - }, - "optionalDependencies": { - "source-map": "~0.6.1" - } - }, - "node_modules/escodegen/node_modules/estraverse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", - "dev": true, - "engines": { - "node": ">=4.0" - } - }, - "node_modules/escodegen/node_modules/levn": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", - "integrity": "sha512-0OO4y2iOHix2W6ujICbKIaEQXvFQHue65vUG3pb5EUomzPI90z9hsA1VsO/dbIIpC53J8gxM9Q4Oho0jrCM/yA==", - "dev": true, - "dependencies": { - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/escodegen/node_modules/optionator": { - "version": "0.8.3", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", - "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", - "dev": true, - "dependencies": { - "deep-is": "~0.1.3", - "fast-levenshtein": "~2.0.6", - "levn": "~0.3.0", - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2", - "word-wrap": "~1.2.3" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/escodegen/node_modules/prelude-ls": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", - "integrity": "sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w==", - "dev": true, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/escodegen/node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true, - "optional": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/escodegen/node_modules/type-check": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", - "integrity": "sha512-ZCmOJdvOWDBYJlzAoFkC+Q0+bUyEOS1ltgp1MGU03fqHG+dbi9tBFU2Rd9QKiDZFAYrhPh2JUf7rZRIuHRKtOg==", - "dev": true, - "dependencies": { - "prelude-ls": "~1.1.2" - }, - "engines": { - "node": ">= 0.8.0" - } - }, "node_modules/eslint": { "version": "8.43.0", "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.43.0.tgz", @@ -3774,19 +3679,6 @@ "node": "^10.12.0 || >=12.0.0" } }, - "node_modules/fill-keys": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/fill-keys/-/fill-keys-1.0.2.tgz", - "integrity": "sha512-tcgI872xXjwFF4xgQmLxi76GnwJG3g/3isB1l4/G5Z4zrbddGpBjqZCO9oEAcB5wX0Hj/5iQB3toxfO7in1hHA==", - "dev": true, - "dependencies": { - "is-object": "~1.0.1", - "merge-descriptors": "~1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/fill-range": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", @@ -4187,15 +4079,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/has-require": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/has-require/-/has-require-1.2.2.tgz", - "integrity": "sha512-JHMVoV2TG3LEFw/8UjxXJzCRGdOHJzzAXft7BafERh2rdPYZcS5N6Twv7Q8yLy9mciKsVBkXmpWSuLp5GUXNng==", - "dev": true, - "dependencies": { - "escape-string-regexp": "^1.0.3" - } - }, "node_modules/has-symbols": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", @@ -4679,15 +4562,6 @@ "node": ">=0.12.0" } }, - "node_modules/is-object": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-object/-/is-object-1.0.2.tgz", - "integrity": "sha512-2rRIahhZr2UWb45fIOuvZGpFtz0TyOZLf32KxBbSoUCeZR495zCKlWUKKUByk3geS2eAs7ZAABt0Y/Rx0GiQGA==", - "dev": true, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/is-path-inside": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", @@ -5524,12 +5398,6 @@ "safe-buffer": "^5.1.2" } }, - "node_modules/merge-descriptors": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", - "integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==", - "dev": true - }, "node_modules/merge-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", @@ -6281,12 +6149,6 @@ "node": ">= 0.8.0" } }, - "node_modules/module-not-found-error": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/module-not-found-error/-/module-not-found-error-1.0.1.tgz", - "integrity": "sha512-pEk4ECWQXV6z2zjhRZUongnLJNUeGQJ3w6OQ5ctGwD+i5o93qjRQUk2Rt6VdNeu3sEP0AB4LcfvdebpxBRVr4g==", - "dev": true - }, "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -7011,15 +6873,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/patch-text": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/patch-text/-/patch-text-1.0.2.tgz", - "integrity": "sha512-r1P+pfiTgWrsMOk/aW64RGv0oLjdyP0LeaLv2dF+iUfaVLqicXRi2dkjGYDgQ/kHVYm4z4GEHnx36Q6uqiFNlA==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/path-browserify": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.1.tgz", @@ -7137,12 +6990,6 @@ "integrity": "sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==", "dev": true }, - "node_modules/pff": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/pff/-/pff-1.0.0.tgz", - "integrity": "sha512-xTEjIRrfxd3e2/xApimUnNSAYmdJ2eUhrjEQqSOYA39oJuytvlWI5p2t3EVBDjl1nquyy327qHMy9fqqXfxZmw==", - "dev": true - }, "node_modules/picocolors": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", @@ -7374,115 +7221,6 @@ "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", "dev": true }, - "node_modules/proxyquire": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/proxyquire/-/proxyquire-2.1.3.tgz", - "integrity": "sha512-BQWfCqYM+QINd+yawJz23tbBM40VIGXOdDw3X344KcclI/gtBbdWF6SlQ4nK/bYhF9d27KYug9WzljHC6B9Ysg==", - "dev": true, - "dependencies": { - "fill-keys": "^1.0.2", - "module-not-found-error": "^1.0.1", - "resolve": "^1.11.1" - } - }, - "node_modules/proxyquire-universal": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/proxyquire-universal/-/proxyquire-universal-3.0.1.tgz", - "integrity": "sha512-BEA0Wb1pd97s3gtBF+Sp82bGEZQiYa+4kOKyM9epd7hDb6w+M4izqpr2z+/WEA1RpU55QaLJME4uSBHFt0c+7A==", - "dev": true, - "dependencies": { - "replace-requires": "~1.1.0", - "through2": "~4.0.1", - "transformify": "^0.1.2" - }, - "engines": { - "node": ">=12" - }, - "peerDependencies": { - "proxyquire": ">= 1 < 3", - "proxyquireify": ">= 1 < 4" - } - }, - "node_modules/proxyquire-universal/node_modules/readable-stream": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", - "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", - "dev": true, - "dependencies": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/proxyquire-universal/node_modules/through2": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/through2/-/through2-4.0.2.tgz", - "integrity": "sha512-iOqSav00cVxEEICeD7TjLB1sueEL+81Wpzp2bY17uZjZN0pWZPuo4suZ/61VujxmqSGFfgOcNuTZ85QJwNZQpw==", - "dev": true, - "dependencies": { - "readable-stream": "3" - } - }, - "node_modules/proxyquireify": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/proxyquireify/-/proxyquireify-3.2.1.tgz", - "integrity": "sha512-JmkrSVx1gArHMCRTtxe+7ycGtkhjsEQMupwJXuM50vxCrPx46MDJPsoyev17vOITtc+RKmUj8o3UFx++wp7XGQ==", - "dev": true, - "dependencies": { - "browser-pack": "^6.0.0", - "detective": "~4.1.0", - "fill-keys": "^1.0.0", - "has-require": "^1.1.0", - "module-not-found-error": "~1.0.1", - "require-deps": "~1.0.1", - "through": "~2.2.7", - "xtend": "^3.0.0" - }, - "peerDependencies": { - "browserify": ">=5.1.0" - } - }, - "node_modules/proxyquireify/node_modules/acorn": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-1.2.2.tgz", - "integrity": "sha512-FsqWmApWGMGLKKNpHt12PMc5AK7BaZee0WRh04fCysmTzHe+rrKOa2MKjORhnzfpe4r0JnfdqHn02iDA9Dqj2A==", - "dev": true, - "bin": { - "acorn": "bin/acorn" - }, - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/proxyquireify/node_modules/detective": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/detective/-/detective-4.1.1.tgz", - "integrity": "sha512-5G4b0VnYUq2/fe68M7YPt8ot6Pi5wylYxYie6UViqYlsWlvadgyZS9pXKonZ0MvdxEvBhYeJ1oBaLsa/sJGUBg==", - "dev": true, - "dependencies": { - "acorn": "^1.0.3", - "defined": "^1.0.0", - "escodegen": "^1.4.1" - } - }, - "node_modules/proxyquireify/node_modules/through": { - "version": "2.2.7", - "resolved": "https://registry.npmjs.org/through/-/through-2.2.7.tgz", - "integrity": "sha512-JIR0m0ybkmTcR8URann+HbwKmodP+OE8UCbsifQDYMLD5J3em1Cdn3MYPpbEd5elGDwmP98T+WbqP/tvzA5Mjg==", - "dev": true - }, - "node_modules/proxyquireify/node_modules/xtend": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-3.0.0.tgz", - "integrity": "sha512-sp/sT9OALMjRW1fKDlPeuSZlDQpkqReA0pyJukniWbTGoEKefHxhGJynE3PNhUMlcM8qWIjPwecwCw4LArS5Eg==", - "dev": true, - "engines": { - "node": ">=0.4" - } - }, "node_modules/public-encrypt": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.3.tgz", @@ -7798,33 +7536,6 @@ "node": ">=4" } }, - "node_modules/replace-requires": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/replace-requires/-/replace-requires-1.1.0.tgz", - "integrity": "sha512-H8Zvb3eOkyjrV948ShbqCitToa7rLx8ctrqsRzzlPzZL27OBS+v77UFKm/FgngvBq0tyg29nlwv7itZ/IgZSOg==", - "dev": true, - "dependencies": { - "detective": "^5.1.0", - "has-require": "~1.2.1", - "patch-text": "~1.0.2", - "xtend": "~4.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/require-deps": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/require-deps/-/require-deps-1.0.1.tgz", - "integrity": "sha512-r4vfNnpbkPK+HQc7kaEVA0qD+zrhRmUAWlwjvVQDtDbMvkw7mLlHGuzfUixQGExPcrPe3/02gOONJ+CUK9PHqw==", - "dev": true, - "dependencies": { - "pff": "~1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -8922,39 +8633,6 @@ "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", "dev": true }, - "node_modules/transformify": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/transformify/-/transformify-0.1.2.tgz", - "integrity": "sha512-BUZAqCslm5pVXExA8PfXcvp7exsUNqRcNzx+KXj3Bv0oMROqnAt4bvs9U8Z2wVPa40NvLWJ/oswN0kreNFxBUg==", - "dev": true, - "dependencies": { - "readable-stream": "~1.1.9" - } - }, - "node_modules/transformify/node_modules/isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==", - "dev": true - }, - "node_modules/transformify/node_modules/readable-stream": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "integrity": "sha512-+MeVjFf4L44XUkhM1eYbD8fyEsxcV81pqMSR5gblfcLCHfZvbrqy4/qYHE+/R5HoBUT11WV5O08Cr1n3YXkWVQ==", - "dev": true, - "dependencies": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "node_modules/transformify/node_modules/string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ==", - "dev": true - }, "node_modules/tslib": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", @@ -12195,73 +11873,6 @@ "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", "dev": true }, - "escodegen": { - "version": "1.14.3", - "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.14.3.tgz", - "integrity": "sha512-qFcX0XJkdg+PB3xjZZG/wKSuT1PnQWx57+TVSjIMmILd2yC/6ByYElPwJnslDsuWuSAp4AwJGumarAAmJch5Kw==", - "dev": true, - "requires": { - "esprima": "^4.0.1", - "estraverse": "^4.2.0", - "esutils": "^2.0.2", - "optionator": "^0.8.1", - "source-map": "~0.6.1" - }, - "dependencies": { - "estraverse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", - "dev": true - }, - "levn": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", - "integrity": "sha512-0OO4y2iOHix2W6ujICbKIaEQXvFQHue65vUG3pb5EUomzPI90z9hsA1VsO/dbIIpC53J8gxM9Q4Oho0jrCM/yA==", - "dev": true, - "requires": { - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2" - } - }, - "optionator": { - "version": "0.8.3", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", - "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", - "dev": true, - "requires": { - "deep-is": "~0.1.3", - "fast-levenshtein": "~2.0.6", - "levn": "~0.3.0", - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2", - "word-wrap": "~1.2.3" - } - }, - "prelude-ls": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", - "integrity": "sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w==", - "dev": true - }, - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true, - "optional": true - }, - "type-check": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", - "integrity": "sha512-ZCmOJdvOWDBYJlzAoFkC+Q0+bUyEOS1ltgp1MGU03fqHG+dbi9tBFU2Rd9QKiDZFAYrhPh2JUf7rZRIuHRKtOg==", - "dev": true, - "requires": { - "prelude-ls": "~1.1.2" - } - } - } - }, "eslint": { "version": "8.43.0", "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.43.0.tgz", @@ -12812,16 +12423,6 @@ "flat-cache": "^3.0.4" } }, - "fill-keys": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/fill-keys/-/fill-keys-1.0.2.tgz", - "integrity": "sha512-tcgI872xXjwFF4xgQmLxi76GnwJG3g/3isB1l4/G5Z4zrbddGpBjqZCO9oEAcB5wX0Hj/5iQB3toxfO7in1hHA==", - "dev": true, - "requires": { - "is-object": "~1.0.1", - "merge-descriptors": "~1.0.0" - } - }, "fill-range": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", @@ -13109,15 +12710,6 @@ "integrity": "sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg==", "dev": true }, - "has-require": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/has-require/-/has-require-1.2.2.tgz", - "integrity": "sha512-JHMVoV2TG3LEFw/8UjxXJzCRGdOHJzzAXft7BafERh2rdPYZcS5N6Twv7Q8yLy9mciKsVBkXmpWSuLp5GUXNng==", - "dev": true, - "requires": { - "escape-string-regexp": "^1.0.3" - } - }, "has-symbols": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", @@ -13474,12 +13066,6 @@ "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", "dev": true }, - "is-object": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-object/-/is-object-1.0.2.tgz", - "integrity": "sha512-2rRIahhZr2UWb45fIOuvZGpFtz0TyOZLf32KxBbSoUCeZR495zCKlWUKKUByk3geS2eAs7ZAABt0Y/Rx0GiQGA==", - "dev": true - }, "is-path-inside": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", @@ -14090,12 +13676,6 @@ "safe-buffer": "^5.1.2" } }, - "merge-descriptors": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", - "integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==", - "dev": true - }, "merge-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", @@ -14644,12 +14224,6 @@ "xtend": "^4.0.0" } }, - "module-not-found-error": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/module-not-found-error/-/module-not-found-error-1.0.1.tgz", - "integrity": "sha512-pEk4ECWQXV6z2zjhRZUongnLJNUeGQJ3w6OQ5ctGwD+i5o93qjRQUk2Rt6VdNeu3sEP0AB4LcfvdebpxBRVr4g==", - "dev": true - }, "ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -15227,12 +14801,6 @@ "lines-and-columns": "^1.1.6" } }, - "patch-text": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/patch-text/-/patch-text-1.0.2.tgz", - "integrity": "sha512-r1P+pfiTgWrsMOk/aW64RGv0oLjdyP0LeaLv2dF+iUfaVLqicXRi2dkjGYDgQ/kHVYm4z4GEHnx36Q6uqiFNlA==", - "dev": true - }, "path-browserify": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.1.tgz", @@ -15327,12 +14895,6 @@ "integrity": "sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==", "dev": true }, - "pff": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/pff/-/pff-1.0.0.tgz", - "integrity": "sha512-xTEjIRrfxd3e2/xApimUnNSAYmdJ2eUhrjEQqSOYA39oJuytvlWI5p2t3EVBDjl1nquyy327qHMy9fqqXfxZmw==", - "dev": true - }, "picocolors": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", @@ -15502,97 +15064,6 @@ "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", "dev": true }, - "proxyquire": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/proxyquire/-/proxyquire-2.1.3.tgz", - "integrity": "sha512-BQWfCqYM+QINd+yawJz23tbBM40VIGXOdDw3X344KcclI/gtBbdWF6SlQ4nK/bYhF9d27KYug9WzljHC6B9Ysg==", - "dev": true, - "requires": { - "fill-keys": "^1.0.2", - "module-not-found-error": "^1.0.1", - "resolve": "^1.11.1" - } - }, - "proxyquire-universal": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/proxyquire-universal/-/proxyquire-universal-3.0.1.tgz", - "integrity": "sha512-BEA0Wb1pd97s3gtBF+Sp82bGEZQiYa+4kOKyM9epd7hDb6w+M4izqpr2z+/WEA1RpU55QaLJME4uSBHFt0c+7A==", - "dev": true, - "requires": { - "replace-requires": "~1.1.0", - "through2": "~4.0.1", - "transformify": "^0.1.2" - }, - "dependencies": { - "readable-stream": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", - "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", - "dev": true, - "requires": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - } - }, - "through2": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/through2/-/through2-4.0.2.tgz", - "integrity": "sha512-iOqSav00cVxEEICeD7TjLB1sueEL+81Wpzp2bY17uZjZN0pWZPuo4suZ/61VujxmqSGFfgOcNuTZ85QJwNZQpw==", - "dev": true, - "requires": { - "readable-stream": "3" - } - } - } - }, - "proxyquireify": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/proxyquireify/-/proxyquireify-3.2.1.tgz", - "integrity": "sha512-JmkrSVx1gArHMCRTtxe+7ycGtkhjsEQMupwJXuM50vxCrPx46MDJPsoyev17vOITtc+RKmUj8o3UFx++wp7XGQ==", - "dev": true, - "requires": { - "browser-pack": "^6.0.0", - "detective": "~4.1.0", - "fill-keys": "^1.0.0", - "has-require": "^1.1.0", - "module-not-found-error": "~1.0.1", - "require-deps": "~1.0.1", - "through": "~2.2.7", - "xtend": "^3.0.0" - }, - "dependencies": { - "acorn": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-1.2.2.tgz", - "integrity": "sha512-FsqWmApWGMGLKKNpHt12PMc5AK7BaZee0WRh04fCysmTzHe+rrKOa2MKjORhnzfpe4r0JnfdqHn02iDA9Dqj2A==", - "dev": true - }, - "detective": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/detective/-/detective-4.1.1.tgz", - "integrity": "sha512-5G4b0VnYUq2/fe68M7YPt8ot6Pi5wylYxYie6UViqYlsWlvadgyZS9pXKonZ0MvdxEvBhYeJ1oBaLsa/sJGUBg==", - "dev": true, - "requires": { - "acorn": "^1.0.3", - "defined": "^1.0.0", - "escodegen": "^1.4.1" - } - }, - "through": { - "version": "2.2.7", - "resolved": "https://registry.npmjs.org/through/-/through-2.2.7.tgz", - "integrity": "sha512-JIR0m0ybkmTcR8URann+HbwKmodP+OE8UCbsifQDYMLD5J3em1Cdn3MYPpbEd5elGDwmP98T+WbqP/tvzA5Mjg==", - "dev": true - }, - "xtend": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-3.0.0.tgz", - "integrity": "sha512-sp/sT9OALMjRW1fKDlPeuSZlDQpkqReA0pyJukniWbTGoEKefHxhGJynE3PNhUMlcM8qWIjPwecwCw4LArS5Eg==", - "dev": true - } - } - }, "public-encrypt": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.3.tgz", @@ -15853,27 +15324,6 @@ "es6-error": "^4.0.1" } }, - "replace-requires": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/replace-requires/-/replace-requires-1.1.0.tgz", - "integrity": "sha512-H8Zvb3eOkyjrV948ShbqCitToa7rLx8ctrqsRzzlPzZL27OBS+v77UFKm/FgngvBq0tyg29nlwv7itZ/IgZSOg==", - "dev": true, - "requires": { - "detective": "^5.1.0", - "has-require": "~1.2.1", - "patch-text": "~1.0.2", - "xtend": "~4.0.0" - } - }, - "require-deps": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/require-deps/-/require-deps-1.0.1.tgz", - "integrity": "sha512-r4vfNnpbkPK+HQc7kaEVA0qD+zrhRmUAWlwjvVQDtDbMvkw7mLlHGuzfUixQGExPcrPe3/02gOONJ+CUK9PHqw==", - "dev": true, - "requires": { - "pff": "~1.0.0" - } - }, "require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -16715,41 +16165,6 @@ "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", "dev": true }, - "transformify": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/transformify/-/transformify-0.1.2.tgz", - "integrity": "sha512-BUZAqCslm5pVXExA8PfXcvp7exsUNqRcNzx+KXj3Bv0oMROqnAt4bvs9U8Z2wVPa40NvLWJ/oswN0kreNFxBUg==", - "dev": true, - "requires": { - "readable-stream": "~1.1.9" - }, - "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==", - "dev": true - }, - "readable-stream": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "integrity": "sha512-+MeVjFf4L44XUkhM1eYbD8fyEsxcV81pqMSR5gblfcLCHfZvbrqy4/qYHE+/R5HoBUT11WV5O08Cr1n3YXkWVQ==", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ==", - "dev": true - } - } - }, "tslib": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", diff --git a/package.json b/package.json index 7fde71264..3e56f78c1 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "scripts": { "test-node": "mocha --recursive -R dot \"test/**/*-test.js\"", "test-dev": "npm run test-node -- --watch -R min", - "test-headless": "mochify --no-detect-globals --recursive -R dot --grep WebWorker --invert --plugin [ proxyquire-universal ] \"test/**/*-test.js\"", + "test-headless": "mochify --no-detect-globals --recursive -R dot --grep WebWorker --invert \"test/**/*-test.js\"", "test-coverage": "nyc npm run test-headless -- --transform [ babelify --ignore [ test ] --plugins [ babel-plugin-istanbul ] ]", "test-cloud": "npm run test-headless -- --wd", "test-webworker": "mochify --no-detect-globals --https-server 8080 --no-request-interception test/webworker/webworker-support-assessment.js", @@ -97,9 +97,6 @@ "mochify": "^9.2.0", "nyc": "^15.1.0", "prettier": "^3.0.3", - "proxyquire": "^2.1.3", - "proxyquire-universal": "^3.0.1", - "proxyquireify": "^3.2.1", "puppeteer": "^21.4.0", "rimraf": "^5.0.5", "semver": "^7.5.4", diff --git a/test/assert-test.js b/test/assert-test.js index 30bbd4737..1f3c8e4bb 100644 --- a/test/assert-test.js +++ b/test/assert-test.js @@ -1,6 +1,7 @@ "use strict"; -const color = require("../lib/sinon/color"); +const Colorizer = require("../lib/sinon/color"); +const color = new Colorizer(); const referee = require("@sinonjs/referee"); const sinonStub = require("../lib/sinon/stub"); const sinonSpy = require("../lib/sinon/spy"); diff --git a/test/proxy-test.js b/test/proxy-test.js index 1d47819aa..05226ae4b 100644 --- a/test/proxy-test.js +++ b/test/proxy-test.js @@ -4,7 +4,8 @@ const assert = require("@sinonjs/referee").assert; const extend = require("../lib/sinon/util/core/extend"); const createProxy = require("../lib/sinon/proxy"); -const color = require("../lib/sinon/color"); +const Colorizer = require("../lib/sinon/color"); +const color = new Colorizer(); const sinonSpy = require("../lib/sinon/spy"); const sinonStub = require("../lib/sinon/stub"); const functionName = require("@sinonjs/commons").functionName; diff --git a/test/sinon-test.js b/test/sinon-test.js index cd3c2dc9d..386e27053 100644 --- a/test/sinon-test.js +++ b/test/sinon-test.js @@ -3,7 +3,6 @@ const assert = require("@sinonjs/referee").assert; const functionName = require("@sinonjs/commons").functionName; const Sandbox = require("../lib/sinon/sandbox"); -const proxyquire = require("proxyquire"); describe("sinon module", function () { let sinon, fakeNise; @@ -32,17 +31,14 @@ describe("sinon module", function () { useFakeXMLHttpRequest: "ba8bd609-c921-4a62-a1b9-49336bd426a4", }, }; - sinon = proxyquire("../lib/sinon", { - nise: fakeNise, + sinon = require("../lib/sinon").createApi({ + sinonXhrLib: fakeNise, }); }); describe("exports", function () { describe("default sandbox", function () { it("should be an instance of Sandbox", function () { - // use full sinon for this test as it compares sinon instance - // proxyquire changes the instance, so `actual instanceof Sandbox` returns `false` - // see https://github.com/sinonjs/sinon/pull/1586#issuecomment-354457231 sinon = require("../lib/sinon"); assert.hasPrototype(sinon, Sandbox.prototype); @@ -113,11 +109,7 @@ describe("sinon module", function () { let nise; beforeEach(function () { - // use full sinon for this test as it compares sinon instance - // proxyquire changes the instance, so `actual instanceof Sandbox` returns `false` - // see https://github.com/sinonjs/sinon/pull/1586#issuecomment-354457231 sinon = require("../lib/sinon"); - nise = require("nise"); }); diff --git a/test/util/core/color-test.js b/test/util/core/color-test.js index e99fcf991..3a9ab8d9d 100644 --- a/test/util/core/color-test.js +++ b/test/util/core/color-test.js @@ -1,7 +1,7 @@ "use strict"; const assert = require("@sinonjs/referee").assert; -const proxyquire = require("proxyquire"); +const Colorizer = require("../../../lib/sinon/color"); const colors = [ { name: "bold", code: 1 }, @@ -16,10 +16,8 @@ describe("color", function () { let color; beforeEach(function () { - color = proxyquire("../../../lib/sinon/color", { - "supports-color": { - stdout: true, - }, + color = new Colorizer({ + stdout: true, }); }); @@ -41,10 +39,8 @@ describe("color", function () { let color; beforeEach(function () { - color = proxyquire("../../../lib/sinon/color", { - "supports-color": { - stdout: false, - }, + color = new Colorizer({ + stdout: false, }); });