Skip to content

Commit be508a4

Browse files
committed
Ci: add a logger if --GGGVERBOSE is specified
Utility to allow tracing to be left in test cases. It would be displayed if --GGGVERBOSE is specified on the npm command. Usage: import logger from "./logger"; logger("some test related data"); Signed-off-by: Chris. Webster <chris@webstech.net>
1 parent 24faef3 commit be508a4

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"transform": {
3636
"\\.(ts|tsx)$": "ts-jest"
3737
},
38-
"testRegex": "/tests/(?!test-lib).*\\.(ts|tsx|js)$"
38+
"testRegex": "/tests/.*\\.test\\.(ts|tsx|js)$"
3939
},
4040
"devDependencies": {
4141
"@types/html-to-text": "^8.1.1",

tests/logger.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Utility to assist in testing. Provides a logger to use if --GGGVERBOSE is specified on the command.
2+
// This makes it easier to leave verbose log info in the source in case it is needed.
3+
// Normal use would be: npm test --GGGVERBOSE some.test.ts
4+
5+
// Using code:
6+
// import logger from "./logger";
7+
// logger("some test related data");
8+
9+
const logger = (() => {
10+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
11+
const debugLog = (...body: any[]) => {
12+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
13+
return console.log(...body);
14+
};
15+
const nodebugLog = () => { return; };
16+
17+
return process.env.npm_config_GGGVERBOSE ? debugLog : nodebugLog;
18+
})();
19+
20+
export default logger;

0 commit comments

Comments
 (0)