supress info log for tests (#1763)

This commit is contained in:
Danish Arora 2024-01-02 16:30:18 +05:30 committed by GitHub
parent 9983549e8b
commit c81872ae0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 27 additions and 26 deletions

View File

@ -28,9 +28,9 @@
"check": "run-s check:*", "check": "run-s check:*",
"check:workspaces": "npm run check --workspaces --if-present", "check:workspaces": "npm run check --workspaces --if-present",
"check:ws": "[ $(ls -1 ./packages|wc -l) -eq $(cat package.json | jq '.workspaces | length') ] || exit 1 # check no packages left behind", "check:ws": "[ $(ls -1 ./packages|wc -l) -eq $(cat package.json | jq '.workspaces | length') ] || exit 1 # check no packages left behind",
"test": "npm run test --workspaces --if-present", "test": "NODE_ENV=test npm run test --workspaces --if-present",
"test:browser": "npm run test:browser --workspaces --if-present", "test:browser": "NODE_ENV=test npm run test:browser --workspaces --if-present",
"test:node": "npm run test:node --workspaces --if-present", "test:node": "NODE_ENV=test npm run test:node --workspaces --if-present",
"proto": "npm run proto --workspaces --if-present", "proto": "npm run proto --workspaces --if-present",
"deploy": "node ci/deploy.js", "deploy": "node ci/deploy.js",
"doc": "run-s doc:*", "doc": "run-s doc:*",

View File

@ -60,9 +60,9 @@
"check:tsc": "tsc -p tsconfig.dev.json", "check:tsc": "tsc -p tsconfig.dev.json",
"check:lint": "eslint src *.js", "check:lint": "eslint src *.js",
"check:spelling": "cspell \"{README.md,src/**/*.ts}\"", "check:spelling": "cspell \"{README.md,src/**/*.ts}\"",
"test": "run-s test:*", "test": "NODE_ENV=test run-s test:*",
"test:node": "TS_NODE_PROJECT=./tsconfig.dev.json mocha", "test:node": "NODE_ENV=test TS_NODE_PROJECT=./tsconfig.dev.json mocha",
"test:browser": "karma start karma.conf.cjs", "test:browser": "NODE_ENV=test karma start karma.conf.cjs",
"watch:build": "tsc -p tsconfig.json -w", "watch:build": "tsc -p tsconfig.json -w",
"watch:test": "mocha --watch", "watch:test": "mocha --watch",
"prepublish": "npm run build", "prepublish": "npm run build",

View File

@ -43,9 +43,9 @@
"check:tsc": "tsc -p tsconfig.dev.json", "check:tsc": "tsc -p tsconfig.dev.json",
"prepublish": "npm run build", "prepublish": "npm run build",
"reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build", "reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build",
"test": "run-s test:*", "test": "NODE_ENV=test run-s test:*",
"test:node": "TS_NODE_PROJECT=./tsconfig.dev.json mocha", "test:node": "NODE_ENV=test TS_NODE_PROJECT=./tsconfig.dev.json mocha",
"test:browser": "karma start karma.conf.cjs" "test:browser": "NODE_ENV=test karma start karma.conf.cjs"
}, },
"engines": { "engines": {
"node": ">=18" "node": ">=18"

View File

@ -41,9 +41,9 @@
"check:lint": "eslint src --ext .ts", "check:lint": "eslint src --ext .ts",
"check:spelling": "cspell \"{README.md,src/**/*.ts}\"", "check:spelling": "cspell \"{README.md,src/**/*.ts}\"",
"check:tsc": "tsc -p tsconfig.dev.json", "check:tsc": "tsc -p tsconfig.dev.json",
"test": "run-s test:*", "test": "NODE_ENV=test run-s test:*",
"test:node": "TS_NODE_PROJECT=./tsconfig.dev.json mocha", "test:node": "NODE_ENV=test TS_NODE_PROJECT=./tsconfig.dev.json mocha",
"test:browser": "karma start karma.conf.cjs", "test:browser": "NODE_ENV=test karma start karma.conf.cjs",
"prepublish": "npm run build", "prepublish": "npm run build",
"reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build" "reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build"
}, },

View File

@ -62,9 +62,9 @@
"check:lint": "eslint src *.js", "check:lint": "eslint src *.js",
"check:spelling": "cspell \"{README.md,src/**/*.ts}\"", "check:spelling": "cspell \"{README.md,src/**/*.ts}\"",
"check:tsc": "tsc -p tsconfig.dev.json", "check:tsc": "tsc -p tsconfig.dev.json",
"test": "run-s test:*", "test": "NODE_ENV=test run-s test:*",
"test:node": "TS_NODE_PROJECT=./tsconfig.dev.json mocha", "test:node": "NODE_ENV=test TS_NODE_PROJECT=./tsconfig.dev.json mocha",
"test:browser": "karma start karma.conf.cjs", "test:browser": "NODE_ENV=test karma start karma.conf.cjs",
"prepublish": "npm run build", "prepublish": "npm run build",
"reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build" "reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build"
}, },

View File

@ -38,9 +38,9 @@
"check:tsc": "tsc -p tsconfig.dev.json", "check:tsc": "tsc -p tsconfig.dev.json",
"check:lint": "eslint src *.js", "check:lint": "eslint src *.js",
"check:spelling": "cspell \"{README.md,src/**/*.ts}\"", "check:spelling": "cspell \"{README.md,src/**/*.ts}\"",
"test": "run-s test:*", "test": "NODE_ENV=test run-s test:*",
"test:node": "TS_NODE_PROJECT=./tsconfig.dev.json mocha", "test:node": "NODE_ENV=test TS_NODE_PROJECT=./tsconfig.dev.json mocha",
"test:browser": "karma start karma.conf.cjs", "test:browser": "NODE_ENV=test karma start karma.conf.cjs",
"watch:build": "tsc -p tsconfig.json -w", "watch:build": "tsc -p tsconfig.json -w",
"watch:test": "mocha --watch", "watch:test": "mocha --watch",
"prepublish": "npm run build", "prepublish": "npm run build",

View File

@ -38,7 +38,7 @@
"check:tsc": "tsc -p tsconfig.dev.json", "check:tsc": "tsc -p tsconfig.dev.json",
"check:lint": "eslint src *.js", "check:lint": "eslint src *.js",
"check:spelling": "cspell \"{README.md,src/**/*.ts}\"", "check:spelling": "cspell \"{README.md,src/**/*.ts}\"",
"test": "run-s test:*", "test": "NODE_ENV=test run-s test:*",
"test:node": "TS_NODE_PROJECT=./tsconfig.dev.json mocha", "test:node": "TS_NODE_PROJECT=./tsconfig.dev.json mocha",
"watch:build": "tsc -p tsconfig.json -w", "watch:build": "tsc -p tsconfig.json -w",
"watch:test": "mocha --watch", "watch:test": "mocha --watch",

View File

@ -185,7 +185,8 @@ export async function defaultLibp2p(
options?: Partial<CreateLibp2pOptions>, options?: Partial<CreateLibp2pOptions>,
userAgent?: string userAgent?: string
): Promise<Libp2p> { ): Promise<Libp2p> {
if (!options?.hideWebSocketInfo) { // Log the info log unless we are running tests or the user has disabled it
if (!options?.hideWebSocketInfo || process.env.NODE_ENV !== "test") {
/* eslint-disable no-console */ /* eslint-disable no-console */
console.info( console.info(
"%cIgnore WebSocket connection failures", "%cIgnore WebSocket connection failures",

View File

@ -41,9 +41,9 @@
"check:lint": "eslint src tests", "check:lint": "eslint src tests",
"check:spelling": "cspell \"{README.md,{tests,src}/**/*.ts}\"", "check:spelling": "cspell \"{README.md,{tests,src}/**/*.ts}\"",
"check:tsc": "tsc -p tsconfig.dev.json", "check:tsc": "tsc -p tsconfig.dev.json",
"test": "run-s test:*", "test": "NODE_ENV=test run-s test:*",
"test:node": "node ./src/run-tests.js \"tests/**/!(*.optional).spec.ts\"", "test:node": "NODE_ENV=test node ./src/run-tests.js \"tests/**/!(*.optional).spec.ts\"",
"test:optional": "node ./src/run-tests.js \"tests/**/@(*.optional).spec.ts\"", "test:optional": "NODE_ENV=test node ./src/run-tests.js \"tests/**/@(*.optional).spec.ts\"",
"reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build" "reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build"
}, },
"engines": { "engines": {

View File

@ -4,7 +4,7 @@ import sinon, { SinonSpy } from "sinon";
import { tearDownNodes } from "../src/index.js"; import { tearDownNodes } from "../src/index.js";
describe("Craete node", () => { describe("Create node", () => {
let waku: LightNode; let waku: LightNode;
let consoleInfoSpy: SinonSpy; let consoleInfoSpy: SinonSpy;

View File

@ -60,8 +60,8 @@
"check:tsc": "tsc -p tsconfig.dev.json", "check:tsc": "tsc -p tsconfig.dev.json",
"prepublish": "npm run build", "prepublish": "npm run build",
"reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build", "reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build",
"test": "run-s test:*", "test": "NODE_ENV=test run-s test:*",
"test:node": "TS_NODE_PROJECT=./tsconfig.dev.json mocha" "test:node": "NODE_ENV=test TS_NODE_PROJECT=./tsconfig.dev.json mocha"
}, },
"engines": { "engines": {
"node": ">=18" "node": ">=18"