Skip to content

Commit fd10f13

Browse files
authored
chore!: remove assert.failException property (#2659)
This was used for allowing customisation of the thrown error between sandboxes and for customisation for integrations (most likely from the days of BusterJS). To my knowledge and what I've been able to find on GitHub, this has never had any _production_ use by end users. BREAKING CHANGE: this removes assert.failException from the API
1 parent c720235 commit fd10f13

File tree

3 files changed

+1
-52
lines changed

3 files changed

+1
-52
lines changed

lib/sinon/assert.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ function createAssertObject(opts) {
4747
});
4848

4949
const assert = {
50-
failException: "AssertError",
51-
5250
fail: function fail(message) {
5351
let msg = message;
5452
if (cleanedAssertOptions.shouldLimitAssertionLogs) {
@@ -58,7 +56,7 @@ function createAssertObject(opts) {
5856
);
5957
}
6058
const error = new Error(msg);
61-
error.name = this.failException || assert.failException;
59+
error.name = "AssertError";
6260

6361
throw error;
6462
},

test/assert-test.js

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,6 @@ describe("assert", function () {
5757
});
5858

5959
describe(".fail", function () {
60-
beforeEach(function () {
61-
this.exceptionName = sinonAssert.failException;
62-
});
63-
64-
afterEach(function () {
65-
sinonAssert.failException = this.exceptionName;
66-
});
67-
6860
it("can be configured to limit the error message length", function () {
6961
const customAssert = sinonAssert.createAssertObject({
7062
shouldLimitAssertionLogs: true,
@@ -87,17 +79,6 @@ describe("assert", function () {
8779
},
8880
);
8981
});
90-
91-
it("throws configured exception type", function () {
92-
sinonAssert.failException = "CustomError";
93-
94-
assert.exception(
95-
function () {
96-
sinonAssert.fail("Some message");
97-
},
98-
{ name: "CustomError" },
99-
);
100-
});
10182
});
10283

10384
describe("with stubs", function () {
@@ -1352,7 +1333,6 @@ describe("assert", function () {
13521333
sinonAssert.expose(test);
13531334

13541335
assert.isFunction(test.fail);
1355-
assert.isString(test.failException);
13561336
assert.isFunction(test.assertCalled);
13571337
assert.isFunction(test.assertCalledOn);
13581338
assert.isFunction(test.assertCalledWith);
@@ -1367,7 +1347,6 @@ describe("assert", function () {
13671347
includeFail: false,
13681348
});
13691349

1370-
assert.equals(typeof failException, "undefined");
13711350
/*eslint-disable no-undef*/
13721351
assert.isFunction(assertCalled);
13731352
assert.isFunction(assertCalledOn);
@@ -1401,7 +1380,6 @@ describe("assert", function () {
14011380
sinonAssert.expose(test, { prefix: "" });
14021381

14031382
assert.isFunction(test.fail);
1404-
assert.isString(test.failException);
14051383
assert.isFunction(test.called);
14061384
assert.isFunction(test.calledOn);
14071385
assert.isFunction(test.calledWith);

test/sandbox-test.js

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1965,31 +1965,4 @@ describe("Sandbox", function () {
19651965
refute.equals(getter, spy.get);
19661966
});
19671967
});
1968-
1969-
describe(".assert", function () {
1970-
it("allows rebinding of .fail on a per-sandbox level", function () {
1971-
const sandboxA = createSandbox();
1972-
const sandboxB = createSandbox();
1973-
1974-
sandboxA.assert.failException = "CustomErrorA";
1975-
sandboxB.assert.failException = "CustomErrorB";
1976-
1977-
assert.exception(
1978-
function () {
1979-
sandboxA.assert.fail("Some message");
1980-
},
1981-
{ name: "CustomErrorA" },
1982-
);
1983-
1984-
assert.exception(
1985-
function () {
1986-
sandboxB.assert.fail("Some message");
1987-
},
1988-
{ name: "CustomErrorB" },
1989-
);
1990-
1991-
sandboxA.restore();
1992-
sandboxB.restore();
1993-
});
1994-
});
19951968
});

0 commit comments

Comments
 (0)