Expect to not see a warning running a test
Seeing a warning running a unit test
I cant seem to figuire out how to run a Jasmine test with StackBlitz, but I copied the example from the sorting section, and created the this unit test.
Which does pass, but throws the warning:
WARN: 'The "longpress" event cannot be bound because Hammer.JS is not loaded and no custom loader has been specified.'
Angular 7.1.4 (down to 7.0.0)
Material 7.2.0
Jasmine 3.3.0
Karma 3.1.4
It's because the sort header is using some gestures from Hammer.js. You should be able to work around it by providing a dummy Hammer loader:
providers: [{
provide: HAMMER_LOADER,
useValue: () => new Promise(() => {})
}]
That indeed worked for me, thank you very much @crisbeto! Closing this issue.
Just another solution in case someone stumbles across this is to add hammer to the scripts arrays in your angular.json
file. eg "scripts": ["node_modules/hammerjs/hammer.min.js"]
If you use jest for testing you can import 'hammerjs' in your jest.ts file.
Adding import 'hammerjs';
into the test.ts
solves the problem.
The one which appears in angular.json
under:
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
...
Adding HammerJs to the scripts
section of angular.json
(as @philmayfield suggested above) didn't help.
@crisbeto adding the code in app.module.ts unfortunately did not solve the issue for me :(
importing hammerjs did thx 馃憤
Adding
import 'hammerjs';
into thetest.ts
solves the problem.
The one which appears inangular.json
under:"test": { "builder": "@angular-devkit/build-angular:karma", "options": { "main": "src/test.ts", ...
Adding HammerJs to the
scripts
section ofangular.json
(as @philmayfield suggested above) didn't help.
That precise suggestion ( from @philmayfield ) resolved my problem. That's weird.
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
It's because the sort header is using some gestures from Hammer.js. You should be able to work around it by providing a dummy Hammer loader: