Unit Testing Jasmine + Karma + PhantomJS


#1

Hey guys,

I have been working 4 days so far trying to fix an error that it’s been raised each time that I run a simple test for Android in Nativescript.

I’m using Nativescript + Angular + Typescript with Jasmine, Karma and PhantomJS.

I use PhantomJS because I’m behind a proxy and we are having problems trying to run the Nativescript Launcher configured in the karma.conf as a base:

android: {
base: ‘PhantomJS’,
platform: ‘android’
}

Until now, I have been able to run the basic test provided when you run tns test init (example.js) and it’s working only if I don’t use any require on it.

Similar problem when I create an “example.ts”. It says that the word import (import “reflect-metadata”) is reserved word.

I have tried all possible approaches I’ve thought of. Does anybody know how to make Unit Tests work properly?

Looks like Nativescript hooks are compiling the code in one JS Version and Karma is running tests in a different one.

With no proxy I haven’t been able to run the basic Nativescript app with Angular and Jasmine in a GenyMotion emulator either.

Please, some help with this topic, there’s a huge lack of information on it.