logos-messaging-js/packages/tests/tests/create.optional.spec.ts
Florin Barbu de5be4413b
chore: use graceful timeout mechanism (#1841)
* use graceful timeout mechanism

* set max timeout for all hooks

* small fix

* small fix

* use MOCHA_HOOK_MAX_TIMEOUT as default timeoutDuration

* force retry even when the hook fails

* use custom hooks

* fix global timeout problem

* fix unwanted change

* fix enr issue

* force retry on before error as well
2024-02-15 08:50:03 +02:00

45 lines
1.3 KiB
TypeScript

import { createLightNode, LightNode } from "@waku/sdk";
import { expect } from "chai";
import sinon, { SinonSpy } from "sinon";
import {
afterEachCustom,
beforeEachCustom,
tearDownNodes
} from "../src/index.js";
describe("Create node", function () {
let waku: LightNode;
let consoleInfoSpy: SinonSpy;
beforeEachCustom(this, async () => {
consoleInfoSpy = sinon.spy(console as any, "info");
});
afterEachCustom(this, async () => {
consoleInfoSpy.restore();
sinon.restore();
await tearDownNodes([], waku);
});
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);
});
[
["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);
});
});
});