From 4f538e3e74580a44e9b0cfcfdec9ca5f76d16fad Mon Sep 17 00:00:00 2001 From: Carl-Erik Kopseng Date: Tue, 24 Oct 2023 11:35:14 +0100 Subject: [PATCH] Fix mochify breaking on node:assert (#2559) * Fix mochify borking on node:assert * refactor: Make 'nise' the default dependency of the constructor --- lib/create-sinon-api.js | 8 +++++--- lib/sinon.js | 3 +-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/create-sinon-api.js b/lib/create-sinon-api.js index 24cd0f77a..8e9d1ca49 100644 --- a/lib/create-sinon-api.js +++ b/lib/create-sinon-api.js @@ -7,15 +7,17 @@ const fakeTimers = require("./sinon/util/fake-timers"); const Sandbox = require("./sinon/sandbox"); const stub = require("./sinon/stub"); const promise = require("./sinon/promise"); -const assert = require("node:assert"); +const nise = require("nise"); +const assert = require("assert"); /** * @param {object} opts injection point to override the default XHR lib in testing * @param {object} opts.sinonXhrLib * @returns {object} a configured sandbox */ -module.exports = function createApi({ sinonXhrLib }) { - assert(sinonXhrLib, "No XHR lib passed in"); +module.exports = function createApi(opts = { sinonXhrLib: nise }) { + assert(opts?.sinonXhrLib, "No XHR lib passed in"); + const { sinonXhrLib } = opts; const apiMethods = { createSandbox: createSandbox, diff --git a/lib/sinon.js b/lib/sinon.js index 271477b65..c9065a902 100644 --- a/lib/sinon.js +++ b/lib/sinon.js @@ -1,6 +1,5 @@ "use strict"; -const nise = require("nise"); const createApi = require("./create-sinon-api"); -module.exports = createApi({ sinonXhrLib: nise }); +module.exports = createApi();