Skip to content

Commit 598dddb

Browse files
mroderickfatso83
authored andcommittedMar 19, 2025·
chore: deprecate useFakeXMLHttpRequest and useFakeServer
1 parent ac93bd9 commit 598dddb

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed
 

‎lib/sinon/sandbox.js

+15-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
const arrayProto = require("@sinonjs/commons").prototypes.array;
44
const logger = require("@sinonjs/commons").deprecated;
5+
const wrap = logger.wrap;
56
const collectOwnMethods = require("./collect-own-methods");
67
const getPropertyDescriptor = require("./util/core/get-property-descriptor");
78
const isPropertyConfigurable = require("./util/core/is-property-configurable");
@@ -506,7 +507,7 @@ function Sandbox(opts = {}) {
506507
}
507508
};
508509

509-
sandbox.useFakeServer = function useFakeServer() {
510+
function useFakeServer() {
510511
const proto = sandbox.serverPrototype || fakeServer;
511512

512513
if (!proto || !proto.create) {
@@ -517,13 +518,23 @@ function Sandbox(opts = {}) {
517518
addToCollection(sandbox.server);
518519

519520
return sandbox.server;
520-
};
521+
}
522+
523+
sandbox.useFakeServer = wrap(
524+
useFakeServer,
525+
"useFakeServer has been deprecated, and will be removed in the next major version",
526+
);
521527

522-
sandbox.useFakeXMLHttpRequest = function useFakeXMLHttpRequest() {
528+
function useFakeXMLHttpRequest() {
523529
const xhr = fakeXhr.useFakeXMLHttpRequest();
524530
addToCollection(xhr);
525531
return xhr;
526-
};
532+
}
533+
534+
sandbox.useFakeXMLHttpRequest = wrap(
535+
useFakeXMLHttpRequest,
536+
"useFakeXMLHttpRequest has been deprecated, and will be removed in the next major version",
537+
);
527538

528539
sandbox.usingPromise = function usingPromise(promiseLibrary) {
529540
promiseLib = promiseLibrary;

0 commit comments

Comments
 (0)
Please sign in to comment.