Skip to content

Commit 056720a

Browse files
committed
fix: stop logging during unit tests
our logs add a lot of noise and don't really contribute to anything when running "npm run test:unit". this commit turns off logs during that context using an envrionment variable NODE_ENV. anything else should be unaffected. "fix" instead of "chore" because this commit changes actual production code and I want it to be treated as such.
1 parent 53ce3a8 commit 056720a

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"scripts": {
66
"pretest": "./scripts/build-image.sh",
77
"test": "npm run lint && npm run build && npm run test:unit && npm run test:integration",
8-
"test:unit": "tap test/unit -R spec",
8+
"test:unit": "NODE_ENV=test tap test/unit -R spec",
99
"test:integration": "TEST_PLATFORM=kind CREATE_CLUSTER=true tap test/integration/kubernetes.test.ts -R spec --timeout=1200",
1010
"test:integration:kind": "TEST_PLATFORM=kind CREATE_CLUSTER=true tap test/integration/kubernetes.test.ts -R spec --timeout=1200",
1111
"test:integration:eks": "TEST_PLATFORM=eks CREATE_CLUSTER=false tap test/integration/kubernetes.test.ts -R spec --timeout=1200",

src/common/logger.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,8 @@ const logger: bunyan = bunyan.createLogger({
1212
},
1313
});
1414

15+
if (process.env.NODE_ENV === 'test') {
16+
logger.level(bunyan.FATAL + 1);
17+
}
18+
1519
export = logger;

0 commit comments

Comments
 (0)