From d510305c1bcc46eecc2bf1d319001109c3717ef3 Mon Sep 17 00:00:00 2001 From: Viktor Date: Tue, 22 Aug 2023 20:11:03 +0300 Subject: [PATCH] fix undefined check, add null test for browser --- src/runtime/browser/util.inspect.polyfil.ts | 2 +- tests/Browser/1_json.test.ts | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/runtime/browser/util.inspect.polyfil.ts b/src/runtime/browser/util.inspect.polyfil.ts index 26a3649..6bb0847 100644 --- a/src/runtime/browser/util.inspect.polyfil.ts +++ b/src/runtime/browser/util.inspect.polyfil.ts @@ -63,7 +63,7 @@ function isBoolean(arg: unknown) { } function isUndefined(arg: unknown) { - return arg == null; + return arg === undefined; } function stylizeNoColor(str: string) { diff --git a/tests/Browser/1_json.test.ts b/tests/Browser/1_json.test.ts index ffb77e2..e232f73 100644 --- a/tests/Browser/1_json.test.ts +++ b/tests/Browser/1_json.test.ts @@ -75,4 +75,14 @@ describe("Browser: JSON: Log level", () => { expect(consoleOutput).toContain("Foo bar"); }); + + it("pretty nullish", async () => { + await page.evaluate(() => { + // @ts-ignore + const logger = new tslog.Logger({ type: "pretty", stylePrettyLogs: false }); + logger.info({ foo: null, bar: undefined }); + }); + expect(consoleOutput).toContain("null"); + expect(consoleOutput).toContain("undefined"); + }); });