Uncaught SyntaxError: Unexpected token import
Here is my angular module,
app.ts:
/// <reference path='../thirdparty/jasmine/jasmine.d.ts'/>
/// <reference path= '../thirdparty/angular/angular.d.ts'/>
import {common} from './modules/common/Common.module';
var app:ng.Imodule= angular.module('comp', [common.name]);
app.test.ts:
/// <reference path='../thirdparty/jasmine/jasmine.d.ts'/>
/// <reference path= '../thirdparty/angular/angular.d.ts'/>
import {comp} from './app';
export function main() {
describe('comp', function () {
it('Comp should be defined', function () {
expect(comp).toBeDefined();
});
});
}
Karma.config.ts
module.exports = function (config) {
config.set({
frameworks: ['jasmine'],
basePath: '',
preprocessors: {
'app/app.ts': ['typescript'],
'app/app.test.ts': ['typescript']
},
typescriptPreprocessor: {
typings: [
'thirdparty/jasmine/jasmine.d.ts',
'node_modules/typescript/typescript.d.ts',
'thirdparty/angular/angular.d.ts',
'thirdparty/jquery/src/jquery.d.ts'
],
options: {
sourceMap: false,
target: 'ES5',
module: 'commonjs',
noImplicitAny: true,
noResolve: true,
removeComments: true,
concatinateOutput: false
},
},
files: [
'app/modules/**/*.module.ts',
'app/app.ts',
'app/app.test.ts',
'node_modules/requirejs/require.js'
],
exclude: [
'modules/**/e2e_test/**',
'app/**/e2e/**/*.js',
'thirdparty/pioneer/featureFlag/**/*{t,T}est.js',
'app/Templates.ts',
'app/routes.ts',
'app/ThirdpartyTemplates.ts'
],
browsers: ['Chrome'],
reporters: ['spec', 'junit'],
specReporter: { maxLogLines: 5 },
junitReporter: {
outputFile: './build/work/jasmine/TEST-results.xml',
suite: 'COMP'
},
port: 9876
});
};
running the test throws error saying that unexpected token import and cannot import app. Not sure whats is wrong. Did some one came across this issue? Can some point where is the mistake.
Same for me using Jasmine in AngularJS2 with NodeJS application.
$ jasmine C:\xampp\htdocs\xxx@xxx\ng2_msButton\spec\msButton.component.spec.js:2 import { ^^^^^^ SyntaxError: Unexpected token import
the preprocessor is just rewritten using https://github.com/sergeyt/typescript-simple, so now it should support all compiler options. Please retry again.
Still exist. How can I use typescript-simple? Do I have to change typescript to typescript-simple here?
preprocessors: {
'app/app.ts': ['typescript'], //['typescript-simple']
'app/app.test.ts': ['typescript']
},
I gave up using karma-typescript-preprocessor in favor of webpack.
My karma.config.js looks like this:
preprocessors: {
"./test/**/**/**.test.ts": ["webpack"]
},
could you share the karma.conf.js to me as reference, which dependencies are required?