When executing tests, each test logs the following:
WARN: 'Could not find HammerJS. Certain Angular Material components may not work correctly.'
From from Angular Material Getting Started Guide :
Some components (
md-slide-toggle
,md-slider
,mdTooltip
) rely on HammerJS for gestures. In order to get the full feature-set of these components, HammerJS must be loaded into the application.
Based on that, my conclusion is that I don't need HammerJS installed as I'm not specifically using the Angular Material components that require it. If you don't need it, don't add it!
But whilst executing 1000+ tests, having that warning print out each time really isn't helpful and so I want to get rid of it or have it print once only.
The following solution will:
new Hammer()
constructor in the future. enableProdMode()
within your test environment so you can continue to benefit from the additional error checking that double change detection provides. Add the following beforeAll
function to your test bundle:
beforeAll(function() {
if (!window.hasOwnProperty('Hammer')) {
window['Hammer'] = function() {
console.error(
'HammerJS is not installed. If you\'re now using Angular Material components that require it, please "npm i hammerjs"'
);
};
console.warn('Could not find HammerJS. Certain Angular Material components may not work correctly.');
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.