Skip to content

Commit 95e8406

Browse files
authored
chore: make tests not silent if DEBUG set (#10130)
this was a gotcha as this is easy to forget. If you want silence, don't set DEBUG
1 parent 8dbeda0 commit 95e8406

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

yarn-project/foundation/src/log/logger.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,14 @@ export type LogLevel = (typeof LogLevels)[number];
1212

1313
function getLogLevel() {
1414
const envLogLevel = process.env.LOG_LEVEL?.toLowerCase() as LogLevel;
15-
const defaultNonTestLogLevel =
16-
process.env.DEBUG === undefined || process.env.DEBUG === '' ? ('info' as const) : ('debug' as const);
17-
const defaultLogLevel = process.env.NODE_ENV === 'test' ? ('silent' as const) : defaultNonTestLogLevel;
15+
let defaultLogLevel: LogLevel = 'info';
16+
if (process.env.DEBUG) {
17+
// if we set DEBUG to a non-empty string, use debug as default
18+
defaultLogLevel = 'debug';
19+
} else if (process.env.NODE_ENV === 'test') {
20+
// otherwise, be silent in tests as these are frequently ran en-masse
21+
defaultLogLevel = 'silent';
22+
}
1823
return LogLevels.includes(envLogLevel) ? envLogLevel : defaultLogLevel;
1924
}
2025

yarn-project/prover-client/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"formatting": "run -T prettier --check ./src && run -T eslint ./src",
2727
"formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src",
2828
"bb": "node --no-warnings ./dest/bb/index.js",
29-
"test": "LOG_LEVEL=${LOG_LEVEL:-silent} DEBUG_COLORS=1 NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --testTimeout=1500000 --forceExit",
29+
"test": "DEBUG_COLORS=1 NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --testTimeout=1500000 --forceExit",
3030
"test:debug": "LOG_LEVEL=debug DEBUG_COLORS=1 NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --testTimeout=1500000 --forceExit --testNamePattern prover/bb_prover/parity"
3131
},
3232
"jest": {
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"scripts": {
3-
"test": "LOG_LEVEL=${LOG_LEVEL:-silent} DEBUG_COLORS=1 NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --testTimeout=1500000 --forceExit"
3+
"test": "DEBUG_COLORS=1 NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --testTimeout=1500000 --forceExit"
44
}
55
}

0 commit comments

Comments
 (0)