Skip to content

Commit 4f538e3

Browse files
authored
Fix mochify breaking on node:assert (#2559)
* Fix mochify borking on node:assert * refactor: Make 'nise' the default dependency of the constructor
1 parent 21d47f2 commit 4f538e3

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

lib/create-sinon-api.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,17 @@ const fakeTimers = require("./sinon/util/fake-timers");
77
const Sandbox = require("./sinon/sandbox");
88
const stub = require("./sinon/stub");
99
const promise = require("./sinon/promise");
10-
const assert = require("node:assert");
10+
const nise = require("nise");
11+
const assert = require("assert");
1112

1213
/**
1314
* @param {object} opts injection point to override the default XHR lib in testing
1415
* @param {object} opts.sinonXhrLib
1516
* @returns {object} a configured sandbox
1617
*/
17-
module.exports = function createApi({ sinonXhrLib }) {
18-
assert(sinonXhrLib, "No XHR lib passed in");
18+
module.exports = function createApi(opts = { sinonXhrLib: nise }) {
19+
assert(opts?.sinonXhrLib, "No XHR lib passed in");
20+
const { sinonXhrLib } = opts;
1921

2022
const apiMethods = {
2123
createSandbox: createSandbox,

lib/sinon.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"use strict";
22

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

6-
module.exports = createApi({ sinonXhrLib: nise });
5+
module.exports = createApi();

0 commit comments

Comments
 (0)