diff --git a/lib/utils.js b/lib/utils.js index d3a928b8b9..ecfefd9285 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -108,6 +108,7 @@ function emptyRepresentation(value, typeHint) { switch (typeHint) { case "function": return "[Function]"; + case "null-prototype": case "object": return "{}"; case "array": diff --git a/test/unit/utils.spec.js b/test/unit/utils.spec.js index 2a7356b52b..150a998aec 100644 --- a/test/unit/utils.spec.js +++ b/test/unit/utils.spec.js @@ -290,6 +290,13 @@ describe("lib/utils", function () { }); describe("should represent null prototypes", function () { + it("Without properties", function () { + const foo = Object.create(null, {}); + const expected = "{}"; + + expect(stringify(foo), "to be", expected); + }); + it("With explicit names", function () { const foo = Object.create(null, { [Symbol.toStringTag]: { value: "Foo" },