Skip to content

Commit

Permalink
Merge branch 'master' into chore/refactors-test-suite
Browse files Browse the repository at this point in the history
  • Loading branch information
danisharora099 authored Jan 17, 2024
2 parents 21d4d99 + 7a8ef87 commit 293c6b9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
3 changes: 1 addition & 2 deletions packages/sdk/src/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,7 @@ export async function defaultLibp2p(
options?: Partial<CreateLibp2pOptions>,
userAgent?: string
): Promise<Libp2p> {
// 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",
Expand Down
19 changes: 14 additions & 5 deletions packages/tests/tests/create.optional.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

0 comments on commit 293c6b9

Please sign in to comment.