diff --git a/src/fake-timers-src.js b/src/fake-timers-src.js index 5741f96..b9a8a8d 100644 --- a/src/fake-timers-src.js +++ b/src/fake-timers-src.js @@ -450,7 +450,10 @@ function withGlobal(_global) { // ensures identity checks using the constructor prop still works // this should have no other functional effect - this.constructor = NativeDate; + Object.defineProperty(this, "constructor", { + value: NativeDate, + enumerable: false, + }); } static [Symbol.hasInstance](instance) { diff --git a/test/fake-timers-test.js b/test/fake-timers-test.js index ae3e8c6..0a4b676 100644 --- a/test/fake-timers-test.js +++ b/test/fake-timers-test.js @@ -3212,6 +3212,12 @@ describe("FakeTimers", function () { assert.equals(date.constructor, realDate.constructor); }); + it("creates Date objects where the constructor prop is not enumerable", function () { + const date = new this.clock.Date(); + + assert.equals(Object.keys(date).length, 0); + }); + it("creates Date objects representing clock time", function () { const date = new this.clock.Date();