/
issues-test.js
902 lines (730 loc) · 28 KB
/
issues-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
"use strict";
const referee = require("@sinonjs/referee");
const sinon = require("../../lib/sinon");
const createStub = require("../../lib/sinon/stub");
const assert = referee.assert;
const refute = referee.refute;
const globalContext = typeof global !== "undefined" ? global : window;
const globalXHR = globalContext.XMLHttpRequest;
const globalAXO = globalContext.ActiveXObject;
describe("issues", function () {
beforeEach(function () {
this.sandbox = sinon.createSandbox();
});
afterEach(function () {
this.sandbox.restore();
});
it("#283", function () {
function testSinonFakeTimersWith(interval, ticks) {
const clock = sinon.useFakeTimers();
const spy = sinon.spy();
const id = setInterval(spy, interval);
assert(!spy.calledOnce);
clock.tick(ticks);
assert(spy.callCount === Math.floor(ticks / interval));
clearInterval(id);
clock.restore();
}
testSinonFakeTimersWith(10, 101);
testSinonFakeTimersWith(99, 101);
testSinonFakeTimersWith(100, 200);
testSinonFakeTimersWith(199, 200);
testSinonFakeTimersWith(500, 1001);
testSinonFakeTimersWith(1000, 1001);
});
describe("#458", function () {
describe("on node", function () {
beforeEach(function () {
if (typeof require("fs").readFileSync !== "function") {
this.skip();
}
});
it("stub out fs.readFileSync", function () {
const fs = require("fs");
const testCase = this;
refute.exception(function () {
testCase.sandbox.stub(fs, "readFileSync");
});
});
});
});
describe("#624", function () {
// eslint-disable-next-line mocha/no-skipped-tests
it.skip("useFakeTimers should be idempotent", function () {
// Issue #624 shows that useFakeTimers is not idempotent when it comes to
// using Date.now
// This test verifies that it's working, at least for Date.now
let clock;
clock = sinon.useFakeTimers(new Date("2014-12-29").getTime());
assert.equals(clock.now, Date.now());
clock = sinon.useFakeTimers(new Date("2015-12-15").getTime());
assert.equals(clock.now, Date.now());
clock = sinon.useFakeTimers(new Date("2015-1-5").getTime());
assert.equals(clock.now, Date.now());
});
});
describe("#852 - createStubInstance on inherited constructors", function () {
it("must not throw error", function () {
const A = function () {
return;
};
const B = function () {
return;
};
B.prototype = Object.create(A.prototype);
B.prototype.constructor = A;
B.prototype.noop = function () {
return;
};
refute.exception(function () {
sinon.createStubInstance(B);
});
});
});
describe("#852(2) - createStubInstance should on same constructor", function () {
it("must be idempotent", function () {
const A = function () {
return;
};
A.prototype.meth = function () {
return;
};
refute.exception(function () {
sinon.createStubInstance(A);
sinon.createStubInstance(A);
});
});
});
describe("#950 - first execution of a spy as a method renames that spy", function () {
function bob() {
return;
}
before(function () {
// IE 11 does not support the function name property
if (!bob.name) {
this.skip();
}
});
it("should not rename spies", function () {
const nameDescriptor = Object.getOwnPropertyDescriptor(bob, "name");
const expectedName =
nameDescriptor && nameDescriptor.configurable ? "bob" : "proxy";
const spy = sinon.spy(bob);
assert.equals(spy.name, expectedName);
const obj = { methodName: spy };
assert.equals(spy.name, expectedName);
spy();
assert.equals(spy.name, expectedName);
obj.methodName.call(null);
assert.equals(spy.name, expectedName);
obj.methodName();
assert.equals(spy.name, expectedName);
obj.otherProp = spy;
obj.otherProp();
assert.equals(spy.name, expectedName);
});
});
describe("#1026", function () {
it("should stub `watch` method on any Object", function () {
// makes sure that Object.prototype.watch is set back to its old value
function restore(oldWatch) {
if (oldWatch) {
Object.prototype.watch = oldWatch; // eslint-disable-line no-extend-native
} else {
delete Object.prototype.watch;
}
}
let oldWatch;
// eslint-disable-next-line no-restricted-syntax
try {
oldWatch = Object.prototype.watch;
if (typeof Object.prototype.watch !== "function") {
// eslint-disable-next-line no-extend-native
Object.prototype.watch = function rolex() {
return;
};
}
const stubbedObject = sinon.stub({
watch: function () {
return;
},
});
stubbedObject.watch();
assert.isArray(stubbedObject.watch.args);
} catch (error) {
restore(oldWatch);
throw error;
}
restore(oldWatch);
});
});
describe("#1154", function () {
it("Ensures different matchers will not be tested against each other", function () {
const match = sinon.match;
const stub = sinon.stub;
const readFile = stub();
function endsWith(str, suffix) {
return str.indexOf(suffix) + suffix.length === str.length;
}
function suffixA(fileName) {
return endsWith(fileName, "suffixa");
}
function suffixB(fileName) {
return endsWith(fileName, "suffixb");
}
const argsA = match(suffixA);
const argsB = match(suffixB);
const firstFake = readFile.withArgs(argsA);
const secondFake = readFile.withArgs(argsB);
assert(firstFake !== secondFake);
});
});
describe("#1372 - sandbox.resetHistory", function () {
it("should reset spies", function () {
const spy = this.sandbox.spy();
spy();
assert.equals(spy.callCount, 1);
spy();
assert.equals(spy.callCount, 2);
this.sandbox.resetHistory();
spy();
assert.equals(spy.callCount, 1); // should not fail but fails
});
});
describe("#1398", function () {
it("Call order takes into account both calledBefore and callCount", function () {
const s1 = sinon.spy();
const s2 = sinon.spy();
s1();
s2();
s1();
assert.exception(function () {
sinon.assert.callOrder(s2, s1, s2);
});
});
});
describe("#1474 - promise library should be propagated through fakes and behaviors", function () {
let stub;
function makeAssertions(fake, expected) {
assert.isFunction(fake.then);
assert.isFunction(fake.tap);
assert.equals(fake.tap(), expected);
}
before(function () {
if (typeof Promise === "undefined") {
this.skip();
}
});
beforeEach(function () {
const promiseLib = {
resolve: function (value) {
const promise = Promise.resolve(value);
promise.tap = function () {
return `tap ${value}`;
};
return promise;
},
};
stub = sinon.stub().usingPromise(promiseLib);
stub.resolves("resolved");
});
it("stub.onCall", function () {
stub.onSecondCall().resolves("resolved again");
makeAssertions(stub(), "tap resolved");
makeAssertions(stub(), "tap resolved again");
});
it("stub.withArgs", function () {
stub.withArgs(42).resolves("resolved again");
stub.withArgs(true).resolves("okay");
makeAssertions(stub(), "tap resolved");
makeAssertions(stub(42), "tap resolved again");
makeAssertions(stub(true), "tap okay");
});
});
describe("#1456", function () {
let sandbox;
function throwsOnUnconfigurableProperty() {
/* eslint-disable no-restricted-syntax */
try {
const preDescriptor = Object.getOwnPropertyDescriptor(
window,
"innerHeight"
); //backup val
Object.defineProperty(window, "innerHeight", {
value: 10,
configurable: true,
writeable: true,
});
Object.defineProperty(window, "innerHeight", preDescriptor); //restore
return false;
} catch (err) {
return true;
}
/* eslint-enable no-restricted-syntax */
}
beforeEach(function () {
if (
typeof window === "undefined" ||
throwsOnUnconfigurableProperty()
) {
this.skip();
}
sandbox = sinon.createSandbox();
});
afterEach(function () {
if (sandbox) {
sandbox.restore();
}
});
it("stub window innerHeight", function () {
sandbox.stub(window, "innerHeight").value(111);
assert.equals(window.innerHeight, 111);
});
});
describe("#1487 - withArgs() returnValue", function () {
beforeEach(function () {
this.stub = createStub().throws("Nothing set");
this.stub.withArgs("arg").returns("return value");
this.stub("arg");
});
it("sets correct firstCall.returnValue", function () {
assert.equals(
this.stub.withArgs("arg").firstCall.returnValue,
"return value"
);
});
it("sets correct lastCall.returnValue", function () {
assert.equals(
this.stub.withArgs("arg").lastCall.returnValue,
"return value"
);
});
});
describe("#1512 - sandbox.stub(obj,protoMethod)", function () {
let sandbox;
beforeEach(function () {
sandbox = sinon.createSandbox();
});
afterEach(function () {
sandbox.restore();
});
it("can stub methods on the prototype", function () {
const proto = {
someFunction: function () {
return;
},
};
const instance = Object.create(proto);
const stub = sandbox.stub(instance, "someFunction");
instance.someFunction();
assert(stub.called);
});
});
describe("#1521 - stubbing Array.prototype.filter", function () {
let orgFilter;
before(function () {
orgFilter = Array.prototype.filter;
});
afterEach(function () {
/* eslint-disable no-extend-native */
Array.prototype.filter = orgFilter;
});
it("should be possible stub filter", function () {
const stub = sinon.stub(Array.prototype, "filter");
[1, 2, 3].filter(function () {
return false;
});
assert(stub.calledOnce);
});
});
describe("#1531 - some copied functions on root sinon module throw", function () {
it("should create a fake server without throwing", function () {
refute.exception(function () {
sinon.createFakeServer();
});
});
it("should create a fake server with clock without throwing", function () {
refute.exception(function () {
sinon.createFakeServerWithClock();
});
});
});
describe("#1442 - callThrough with a mock expectation", function () {
it("should call original method", function () {
const foo = {
bar: function () {
return;
},
};
const mock = this.sandbox.mock(foo);
mock.expects("bar").callThrough();
foo.bar();
mock.verify();
});
});
describe("#1648 - resetHistory ", function () {
it("should reset property spies", function () {
const obj = {
func: function () {
return;
},
get prop() {
return 1;
},
};
const sandbox = sinon.createSandbox();
const spyFunc = sandbox.spy(obj, "func");
const spyProp = sandbox.spy(obj, "prop", ["get"]);
refute.isTrue(spyFunc.called);
refute.isTrue(spyProp.get.called);
obj.func();
//eslint-disable-next-line no-unused-expressions
obj.prop;
assert.isTrue(spyFunc.called);
assert.isTrue(spyProp.get.called);
sandbox.resetHistory();
refute.isTrue(spyFunc.called);
refute.isTrue(spyProp.get.called);
});
});
// this error was caused by overwriting methods with imported ones don't use the collection
// and thus were not restorable
describe("#1775 - sinon.restore", function () {
it("should restore all stubs", function () {
const myApi = {
someMethod: function someMethod() {
// eslint-disable-next-line no-console
console.log("test method!");
},
};
sinon.stub(myApi, "someMethod");
sinon.restore();
sinon.stub(myApi, "someMethod");
// TypeError: Attempted to wrap someMethod which is already wrapped
});
it("should restore all spies", function () {
const myApi = {
someMethod: function someMethod() {
// eslint-disable-next-line no-console
console.log("test method!");
},
};
sinon.spy(myApi, "someMethod");
sinon.restore();
sinon.spy(myApi, "someMethod");
// TypeError: Attempted to wrap someMethod which is already wrapped
});
it("should restore all mocks", function () {
const myApi = {
someMethod: function someMethod() {
// eslint-disable-next-line no-console
console.log("test method!");
},
};
sinon.mock(myApi);
sinon.restore();
sinon.mock(myApi);
// TypeError: Attempted to wrap someMethod which is already wrapped
});
});
describe("#1801 - sinon.restore spied fakeTimers", function () {
it("should restore spied fake timers", function () {
const originalSetTimeout = setTimeout;
sinon.useFakeTimers();
sinon.spy(globalContext, "setTimeout");
sinon.restore();
assert.same(
originalSetTimeout,
globalContext.setTimeout,
"fakeTimers restored"
);
});
});
describe("#1840 - sinon.restore useFakeXMLHttpRequest", function () {
it("should restore XMLHttpRequest and ActiveXObject", function () {
sinon.useFakeXMLHttpRequest();
sinon.restore();
assert.same(globalContext.XMLHttpRequest, globalXHR);
assert.same(globalContext.ActiveXObject, globalAXO);
});
});
describe("#1709 - deepEqual fails on cyclic references", function () {
it("should not blow up", function () {
const spy = sinon.spy();
const firstObj = {};
firstObj.aKeyName = firstObj;
const secondObj = {};
secondObj.aKeyName = secondObj;
spy(firstObj);
sinon.assert.calledWith(spy, secondObj);
});
});
describe("#1796 - cannot stub Array.prototype.sort", function () {
it("it should not fail with RangeError", function () {
const stub = sinon.stub(Array.prototype, "sort");
refute.exception(function () {
[1, 2, 3].sort();
});
stub.restore();
});
});
describe("#1900 - calledWith returns false positive", function () {
it("should return false when call args don't match", function () {
const spy = sinon.spy();
const dateOne = new Date("2018-07-01");
const dateTwo = new Date("2018-07-31");
spy(dateOne);
const calledWith = spy.calledWith(dateTwo);
assert.same(calledWith, false);
});
});
describe("#1882", function () {
it("should use constructor name when checking deepEquality", function () {
function ClassWithoutProps() {
return;
}
function AnotherClassWithoutProps() {
return;
}
ClassWithoutProps.prototype.constructor = ClassWithoutProps;
AnotherClassWithoutProps.prototype.constructor =
AnotherClassWithoutProps;
const arg1 = new ClassWithoutProps(); //arg1.constructor.name === ClassWithoutProps
const arg2 = new AnotherClassWithoutProps(); //arg2.constructor.name === Object
const stub = sinon.stub();
stub.withArgs(arg1).returns(5);
const result = stub(arg2);
assert.same(result, undefined); //[ERR_ASSERTION]: 5 === undefined
});
});
describe("#1887", function () {
it("should not break stub behavior using multiple `match.any`", function () {
const stub = sinon.stub();
stub.withArgs(
sinon.match.any,
sinon.match.any,
sinon.match("a")
).returns("a");
stub.withArgs(
sinon.match.any,
sinon.match.any,
sinon.match("b")
).returns("b");
assert.equals(stub({}, [], "a"), "a");
assert.equals(stub({}, [], "b"), "b");
});
});
describe("#1986", function () {
it("should not set `lastArg` to undefined when last argument is `false`", function () {
const fake = sinon.fake();
fake(99, false);
assert.isFalse(fake.lastArg);
});
});
describe("#1964", function () {
it("should allow callThrough on a withArgs fake", function () {
let calledThrough = false;
const obj = {
method: function () {
calledThrough = true;
},
};
const baseStub = sinon.stub(obj, "method");
baseStub.throws("Should always hit the withArgs fake");
const argsStub = baseStub.withArgs("foo").callThrough();
obj.method("foo");
sinon.assert.calledOnce(argsStub);
assert.isTrue(calledThrough);
});
});
describe("#2016", function () {
function Foo() {
return;
}
// eslint-disable-next-line mocha/no-setup-in-describe
Foo.prototype.testMethod = function () {
return;
};
let sandbox;
beforeEach(function () {
sandbox = sinon.createStubInstance(Foo);
});
afterEach(function () {
sinon.restore();
});
describe("called on individual stub method", function () {
it("should clear 'called' status on stub", function () {
sandbox.testMethod();
assert.isTrue(sandbox.testMethod.called);
sandbox.testMethod.resetHistory();
assert.isFalse(sandbox.testMethod.called);
});
});
describe("called on module", function () {
it("should clear 'called' status on all stubs", function () {
sandbox.testMethod();
assert.isTrue(sandbox.testMethod.called);
sinon.resetHistory();
assert.isFalse(sandbox.testMethod.called);
});
});
});
describe("#2073 - sinon.createStubInstance()", function () {
function Foo() {
return;
}
// eslint-disable-next-line mocha/no-setup-in-describe
Foo.prototype.testMethod = function () {
return 1;
};
it("should override the method", function () {
const thing = sinon.createStubInstance(Foo, {
testMethod: sinon.stub().returns(2),
});
assert.equals(thing.testMethod(), 2);
});
it("should support calling without object binding", function () {
const createStubInstance = sinon.createStubInstance;
refute.exception(function () {
createStubInstance(Foo);
});
});
});
describe("#2065", function () {
it("should restore the state of lastArg on the stub when resetting the sandbox", function () {
const sandbox = sinon.createSandbox();
const fake = sandbox.fake();
fake(1, 2, 3);
assert.equals(fake.lastArg, 3);
sandbox.reset();
refute.equals(fake.lastArg, 3);
});
});
describe("#2226 - props on prototype are not restored correctly", function () {
function createObjectWithPropFromPrototype() {
const proto = {};
const obj = {};
Object.setPrototypeOf(obj, proto);
Object.defineProperty(proto, "test", { writable: true, value: 1 });
return obj;
}
it("should restore fakes shadowing prototype props correctly", function () {
const obj = createObjectWithPropFromPrototype();
const originalPropertyDescriptor = Object.getOwnPropertyDescriptor(
obj,
"test"
);
sinon.replace(obj, "test", 2);
const replacedPropertyDescriptor = Object.getOwnPropertyDescriptor(
obj,
"test"
);
sinon.restore();
const restoredPropertyDescriptor = Object.getOwnPropertyDescriptor(
obj,
"test"
);
assert.isUndefined(originalPropertyDescriptor);
refute.isUndefined(replacedPropertyDescriptor);
assert.isUndefined(restoredPropertyDescriptor);
});
it("should restore stubs shadowing prototype props correctly", function () {
const obj = createObjectWithPropFromPrototype();
const originalPropertyDescriptor = Object.getOwnPropertyDescriptor(
obj,
"test"
);
sinon.stub(obj, "test").value(2);
const replacedPropertyDescriptor = Object.getOwnPropertyDescriptor(
obj,
"test"
);
sinon.restore();
const restoredPropertyDescriptor = Object.getOwnPropertyDescriptor(
obj,
"test"
);
assert.isUndefined(originalPropertyDescriptor);
refute.isUndefined(replacedPropertyDescriptor);
assert.isUndefined(restoredPropertyDescriptor);
});
});
describe("#2501 - createStubInstance stubs are not able to call through to the underlying function on the prototype", function () {
it("should be able call through to the underlying function on the prototype", function () {
class Foo {
testMethod() {
this.wasCalled = true;
return 42;
}
}
const fooStubInstance = this.sandbox.createStubInstance(Foo);
assert.isUndefined(fooStubInstance.wasCalled);
fooStubInstance.testMethod.callThrough();
fooStubInstance.testMethod();
assert.isTrue(fooStubInstance.wasCalled);
});
});
describe("#2491 - unable to restore spies on an instance where the prototype has an unconfigurable property descriptor", function () {
function createInstanceFromClassWithReadOnlyPropertyDescriptor() {
class BaseClass {}
Object.defineProperty(BaseClass.prototype, "aMethod", {
value: function () {
return 42;
},
});
// anchor
const instance = new BaseClass();
assert.equals(instance.aMethod(), 42);
return instance;
}
it("should ensure copied object descriptors are always configurable for spies", function () {
const instance =
createInstanceFromClassWithReadOnlyPropertyDescriptor();
this.sandbox.spy(instance, "aMethod");
refute.exception(() => {
this.sandbox.restore(); // #2491: this throws TypeError: Cannot assign to read only property 'myMethod' of object '#<BaseClass>'
});
});
it("should not throw if the unconfigurable object descriptor to be used for a Stub is on the prototype", function () {
const instance =
createInstanceFromClassWithReadOnlyPropertyDescriptor();
// per #2491 this throws 'TypeError: Descriptor for property aMethod is non-configurable and non-writable'
// that makes sense for descriptors taken from the object, but not its prototype, as we are free to change
// the latter when setting it
refute.exception(() => {
this.sandbox.stub(instance, "aMethod").returns("a stub");
});
});
it("should not throw if the unconfigurable object descriptor to be used for a Mock is on the prototype", function () {
const instance =
createInstanceFromClassWithReadOnlyPropertyDescriptor();
const mock = this.sandbox.mock(instance);
// per #2491 this throws 'TypeError: Attempted to wrap undefined property myMethod as function
refute.exception(() => {
mock.expects("aMethod").once();
});
});
});
describe("#2514 (regression from fixing #2491) - writable object descriptors that are unconfigurable should be assignable", function () {
function createInstanceWithWritableUconfigurablePropertyDescriptor() {
const instance = {};
Object.defineProperty(instance, "aMethod", {
writable: true,
configurable: false,
value: function () {
return 42;
},
});
return instance;
}
it("should be able to assign and restore unconfigurable descriptors that are writable", function () {
const o =
createInstanceWithWritableUconfigurablePropertyDescriptor();
refute.exception(() =>
this.sandbox.stub(o, "aMethod").returns("stubbed")
);
assert.equals("stubbed", o.aMethod());
this.sandbox.restore();
});
});
});