import assert from "assert"; import util from "util"; test("no assertion failures", () => { // Errors in accessors are not triggered const obj = new Proxy( { x: 5 }, { get() { throw new Error("Error message"); }, }, ); assert.strictEqual(util.format(obj), "{ x: 5 }"); assert.strictEqual(util.formatWithOptions({ numericSeparator: true }, "%d", 4000), "4_000"); const a = {}; a.b = a; assert.strictEqual(util.inspect(a, { compact: false }), " {\n b: [Circular *1]\n}"); assert.strictEqual(util.inspect(a, { compact: true }), " { b: [Circular *1] }"); const cause = new Error("cause"); const e2 = new Error("wrapper", { cause }); assert.match(util.inspect(e2), /\[cause\]: Error: cause\n/); }); //! non-standard property, should this be kept? test.skip("util.stylizeWithHTML", () => { assert.strictEqual( util.inspect( { a: 1, b: "

\xA0\u{1F4A9}

", "<": NaN, [Symbol("
")]: false, buf: new Uint8Array([1, 2, 3, 4]), }, { compact: false, stylize: util.stylizeWithHTML, }, ), "{\n" + ' a: 1,\n' + ' b: '<p> \u{1F4A9}</p>',\n' + ' '&lt;': NaN,\n' + " buf: Uint8Array(4) [\n" + ' 1,\n' + ' 2,\n' + ' 3,\n' + ' 4\n' + " ],\n" + ' [Symbol(<br>)]: false\n' + "}", ); });