Skip to content

Commit

Permalink
Fix mochify breaking on node:assert (#2559)
Browse files Browse the repository at this point in the history
* Fix mochify borking on node:assert

* refactor: Make 'nise' the default dependency of the constructor
  • Loading branch information
fatso83 committed Oct 24, 2023
1 parent 21d47f2 commit 4f538e3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 5 additions & 3 deletions lib/create-sinon-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions lib/sinon.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"use strict";

const nise = require("nise");
const createApi = require("./create-sinon-api");

module.exports = createApi({ sinonXhrLib: nise });
module.exports = createApi();

0 comments on commit 4f538e3

Please sign in to comment.