diff --git a/packages/sdk/src/create.ts b/packages/sdk/src/create.ts index 4265fb6f4b..a383388d60 100644 --- a/packages/sdk/src/create.ts +++ b/packages/sdk/src/create.ts @@ -212,8 +212,7 @@ export async function defaultLibp2p( options?: Partial, userAgent?: string ): Promise { - // Log the info log unless we are running tests or the user has disabled it - if (!options?.hideWebSocketInfo || process.env.NODE_ENV !== "test") { + if (!options?.hideWebSocketInfo && process.env.NODE_ENV !== "test") { /* eslint-disable no-console */ console.info( "%cIgnore WebSocket connection failures", diff --git a/packages/tests/tests/create.optional.spec.ts b/packages/tests/tests/create.optional.spec.ts index a09a01d16b..d098487a52 100644 --- a/packages/tests/tests/create.optional.spec.ts +++ b/packages/tests/tests/create.optional.spec.ts @@ -14,18 +14,27 @@ describe("Create node", () => { afterEach(async () => { consoleInfoSpy.restore(); + sinon.restore(); await tearDownNodes([], waku); }); - it("should log info about WebSocket failures to console when hideWebSocketInfo disabled", async () => { + it("should log info about WebSocket failures to console when hideWebSocketInfo disabled and NODE_ENV is not test", async () => { + sinon.stub(process.env, "NODE_ENV").value("undefined"); waku = await createLightNode(); expect(consoleInfoSpy.callCount).to.be.equal(2); }); - it("should not log info about WebSocket failures to console when hideWebSocketInfo enabled", async () => { - waku = await createLightNode({ - libp2p: { hideWebSocketInfo: true } + [ + ["test", false], + ["test", true], + [undefined, true] + ].map(([env, hideWebSocketInfo]) => { + it(`should not log info about WebSocket failures to console when NODE_ENV=${env} and hideWebSocketInfo=${hideWebSocketInfo}`, async () => { + sinon.stub(process.env, "NODE_ENV").value(env); + waku = await createLightNode({ + libp2p: { hideWebSocketInfo: !!hideWebSocketInfo } + }); + expect(consoleInfoSpy.callCount).to.be.equal(0); }); - expect(consoleInfoSpy.callCount).to.be.equal(0); }); });