Skip to content

Commit

Permalink
refactor: add a debug flag to enable console log msg and silence by d…
Browse files Browse the repository at this point in the history
…efault
  • Loading branch information
mohanraj-r committed Jun 21, 2021
1 parent fcc2646 commit 88c30a6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"test": "jest --coverage --runInBand",
"test:ci": "yarn lint:all && yarn test --ci && yarn test:wdio",
"test:clean": "yarn build:clean && yarn test:ci",
"test:debug": "node --inspect node_modules/.bin/jest --runInBand --watch",
"test:debug": "SA11Y_DEBUG=1 node --inspect node_modules/.bin/jest --runInBand --watch",
"test:watch": "jest --watch",
"test:auto": "SA11Y_AUTO=1 yarn test --json --outputFile jestResults.json",
"test:wdio": "wdio run wdio.conf.js --suite wdio --suite integration --suite browserLib < /dev/null",
Expand Down
5 changes: 4 additions & 1 deletion packages/common/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@

/**
* Convenience wrapper to prefix a standard header for console log messages.
* Logging is enabled only when environment variable `SA11Y_DEBUG` is set.
*/
export function log(...args: unknown[]): void {
console.log('♿[Sa11y]', ...args);
// Probably not worth it to mock and test console logging for this helper util
/* istanbul ignore next */
if (process.env.SA11Y_DEBUG) console.log('♿[Sa11y]', ...args);
}

0 comments on commit 88c30a6

Please sign in to comment.