Search code examples
unit-testingangular-clikarma-jasminekarma-runnerlog4js-node

log4js-node-DEP0004 - Deprecation warning in Angular 12 karma unit tests


I'm getting the following deprecation warning when running unit tests in a brand new Angular 12 application:

(node:14940) [log4js-node-DEP0004] DeprecationWarning: Pattern %d{DATE} is deprecated due to the confusion it causes when used. Please use %d{DATETIME} instead.

enter image description here

why log4js prompts "karma" depends on it. The warning itself is clear as to what should be done but there are two key missing pieces of information:

  • it doesn't say when/if the old syntax will stop working
  • it doesn't provide a workaround (other than forking karma and replacing the deprecated syntax with the new one - which I'm definitely not going to do).

Downgrading log4js to an earlier version, which doesn't output the warning, using forceResolutions doesn't seem like a good idea, especially since I've found a few github threads related to vulnerabilities in it, although karma doesn't seem to be affected.

The question: are there actionable paths for not getting the warning, or is "and now we wait" (for a karma update) the only option?

Note: I've also asked it on karma's repo.


Solution

  • Got the fix from karma maintainers:

    Update karma (in package.json > devDependencies.karma) to ^6.3.12.

    Warnings gone. Well done, karma. That was fast!