Angular Material warnings shown when unit testing component -
i writing units test angular components make use of angular material. issue having keep getting following warnings when running unit tests.
console.warn node_modules\@angular\material\bundles\material.umd.js:183 current document not have doctype. may cause angular material components not behave expected. console.warn node_modules\@angular\material\bundles\material.umd.js:196 not find angular material core theme. material components may not work expected. more info refer theming guide: https://material.ang ular.io/guide/theming console.warn node_modules\@angular\material\bundles\material.umd.js:3327 not find hammerjs. angular material components may not work correctly.
is normal see these warnings? ideas on how suppress these warnings don't see them relevant unit testing?
found hack of suppressing warnings. in jest configuration, there's option set script files can configure jest testing framework.
"jest": { "setuptestframeworkscriptfile": "<rootdir>/src/setup.ts", }
see setuptestframeworkscriptfile option jest api doc
the path module runs code configure or set testing framework before each test. since setupfiles executes before test framework installed in environment, script file presents opportunity of running code after test framework has been installed in environment.
then in setup.ts
, following suppress warnings.
console.warn = function() {};
probably not ideal way, did trick.
Comments
Post a Comment