Unit testing failing with native facebook plugin

#1

I was porting my ionic 3 application to ionic 4 when I discovered an issue with unit testing. I have a service called ‘AuthService’ which injects the ionic-native facebook plugin. When running the default created unit test on this service (just creating the auth service object), my unit test freezes and when I open the console in my browser I got stack trace below. Anyone got some ideas what is causing this? Didn’t had this issue in ionic 3.

Uncaught TypeError: Object(…) is not a function
at eval (index.js:469)
at eval (index.js:623)
at Object…/node_modules/@ionic-native/facebook/index.js (vendor.js:334)
at webpack_require (main.js:82)
at eval (auth.service.ts:15)
at Object…/src/app/services/auth/auth.service.ts (main.js:260)
at webpack_require (main.js:82)
at eval (auth.service.spec.ts:4)
at Object…/src/app/services/auth/auth.service.spec.ts (main.js:248)
at webpack_require (main.js:82)

#2

Angular 6 has changed several things. About an hour ago, I had to add something to polyfill.ts for the first time, because global is no longer recognized in Angular 6. It was a webpack issue, like yours. I don’t recognize your error message, but I suggest you search issues on Angular 6 and Angular CLI.

#3

Found my problem, was still using version 4.x from @ionic-native/facebook, now upgraded to 5.0.0-beta.14 and imported Facebook from @ionic-native/facebook/ngx which solves the problem.