Karma test setup on latest ionic-native / ng2


#1

Hi everyone,

I’m having trouble setting up Karma to work with latest ionic-native and ng2 libs. After correctly (?) setting up karma using the numerous forum and stackoverflow posts, the proxy to ionic-native works fine, but then it complains of:

WARN [proxy]: failed to proxy ./node_modules/ionic-native/dist/ng1.js (socket hang up)
WARN [proxy]: failed to proxy ./node_modules/ionic-native/dist/plugins/actionsheet.js (socket hang up)
WARN [proxy]: failed to proxy ./node_modules/ionic-native/dist/plugins/android-fingerprint-auth.js (socket hang up)
WARN [proxy]: failed to proxy ./node_modules/ionic-native/dist/plugins/appavailability.js (socket hang up)
WARN [proxy]: failed to proxy ./node_modules/ionic-native/dist/plugins/apprate.js (socket hang up)
WARN [proxy]: failed to proxy ./node_modules/ionic-native/dist/plugins/admob.js (socket hang up)
WARN [proxy]: failed to proxy ./node_modules/ionic-native/dist/ng1.js (socket hang up)
WARN [proxy]: failed to proxy ./node_modules/ionic-native/dist/plugins/actionsheet.js (socket hang up)
WARN [proxy]: failed to proxy ./node_modules/ionic-native/dist/plugins/android-fingerprint-auth.js (socket hang up)
WARN [proxy]: failed to proxy ./node_modules/ionic-native/dist/plugins/appavailability.js (socket hang up)
WARN [proxy]: failed to proxy ./node_modules/ionic-native/dist/plugins/apprate.js (socket hang up)
WARN [proxy]: failed to proxy ./node_modules/ionic-native/dist/plugins/admob.js (socket hang up)

And then a final failure with this:
PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR
{
“stack”: “(SystemJS) XHR error loading node_modules/ionic-native/dist/ng1.js\n\tError loading node_modules/ionic-native/dist/ng1.js as “./ng1” from node_modules/ionic-native/dist/ionic.native.js”,
“originalErr”: {},
“line”: 791,
“sourceURL”: “node_modules/systemjs/dist/system.src.js”
}

08 11 2016 10:24:18.510:ERROR [PhantomJS 2.1.1 (Mac OS X 0.0.0)]: { stack: ‘(SystemJS) XHR error loading http://localhost:9876/base/node_modules/ionic-native/dist/ng1.js\n\tError loading http://localhost:9876/base/node_modules/ionic-native/dist/ng1.js as “./ng1” from http://localhost:9876/base/node_modules/ionic-native/dist/ionic.native.js’,
originalErr: {},
line: 791,
sourceURL: ‘http://localhost:9876/base/node_modules/systemjs/dist/system.src.js?3ff30a454997746a9b3130d627eb0d7441f0fc52’ }

As you can notice, is looks for dist/ng1.js, but the ng1 only exists in either es5 or esm. I also gave directly proxy to es5, but then the same error in a different fashion. I just cannot figure out what is wrong here and I’ve done a lot of searches and trial/error to get this working.

Does anyone here know what could be wrong or what should I do to make it work?

Thanks,
Jay